expdpy 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- expdpy/__init__.py +147 -0
- expdpy/_assets/favicon.png +0 -0
- expdpy/_assets/favicon.svg +12 -0
- expdpy/_assets/logo-navbar.svg +14 -0
- expdpy/_assets/logo.png +0 -0
- expdpy/_assets/logo.svg +14 -0
- expdpy/_corr.py +80 -0
- expdpy/_estimation/__init__.py +38 -0
- expdpy/_estimation/_capture.py +26 -0
- expdpy/_estimation/_fit.py +56 -0
- expdpy/_estimation/_formula.py +50 -0
- expdpy/_estimation/_results.py +30 -0
- expdpy/_estimation/_spec.py +112 -0
- expdpy/_estimation/_tidy.py +35 -0
- expdpy/_estimation/_vcov.py +52 -0
- expdpy/_theme.py +201 -0
- expdpy/_types.py +505 -0
- expdpy/_validation.py +43 -0
- expdpy/app/__init__.py +766 -0
- expdpy/app/_components.py +282 -0
- expdpy/app/_config_io.py +63 -0
- expdpy/app/_export_nb.py +234 -0
- expdpy/app/_sample.py +124 -0
- expdpy/app/_state.py +102 -0
- expdpy/app/_udv.py +179 -0
- expdpy/app/_upload.py +43 -0
- expdpy/app/_varcat.py +100 -0
- expdpy/by_group.py +313 -0
- expdpy/coefplot.py +236 -0
- expdpy/correlation.py +152 -0
- expdpy/data/__init__.py +103 -0
- expdpy/data/expdpy_config_kuznets.json +54 -0
- expdpy/data/gapminder.parquet +0 -0
- expdpy/data/gapminder_data_def.parquet +0 -0
- expdpy/data/kuznets.parquet +0 -0
- expdpy/data/kuznets_data_def.parquet +0 -0
- expdpy/data/staggered_did.parquet +0 -0
- expdpy/data/staggered_did_data_def.parquet +0 -0
- expdpy/did.py +405 -0
- expdpy/distributions.py +130 -0
- expdpy/estimation.py +282 -0
- expdpy/fwl.py +284 -0
- expdpy/inference.py +92 -0
- expdpy/missing.py +117 -0
- expdpy/outliers.py +180 -0
- expdpy/panel_models.py +244 -0
- expdpy/pedagogy/__init__.py +43 -0
- expdpy/pedagogy/_format.py +88 -0
- expdpy/pedagogy/_interpret.py +355 -0
- expdpy/pedagogy/_mixin.py +44 -0
- expdpy/pedagogy/_registry.py +121 -0
- expdpy/pedagogy/_text/__init__.py +11 -0
- expdpy/pedagogy/_text/causal.py +65 -0
- expdpy/pedagogy/_text/correlation.py +77 -0
- expdpy/pedagogy/_text/outliers.py +53 -0
- expdpy/pedagogy/_text/regression.py +257 -0
- expdpy/pedagogy/_text/tables.py +51 -0
- expdpy/postestimation.py +202 -0
- expdpy/py.typed +0 -0
- expdpy/regression.py +201 -0
- expdpy/sandbox.py +307 -0
- expdpy/scatter.py +207 -0
- expdpy/streamlit_app/__init__.py +106 -0
- expdpy/streamlit_app/_context.py +99 -0
- expdpy/streamlit_app/_entry.py +57 -0
- expdpy/streamlit_app/_handoff.py +149 -0
- expdpy/streamlit_app/_launcher.py +103 -0
- expdpy/streamlit_app/_pages.py +424 -0
- expdpy/streamlit_app/_pipeline.py +99 -0
- expdpy/streamlit_app/_render.py +221 -0
- expdpy/streamlit_app/_run.py +9 -0
- expdpy/streamlit_app/_sidebar.py +258 -0
- expdpy/streamlit_app/_widgets.py +95 -0
- expdpy/tables.py +348 -0
- expdpy/trends.py +263 -0
- expdpy-0.2.0.dist-info/METADATA +203 -0
- expdpy-0.2.0.dist-info/RECORD +80 -0
- expdpy-0.2.0.dist-info/WHEEL +4 -0
- expdpy-0.2.0.dist-info/entry_points.txt +2 -0
- expdpy-0.2.0.dist-info/licenses/LICENSE +25 -0
expdpy/_validation.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Shared input-validation helpers used across the analytical functions."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import pandas as pd
|
|
6
|
+
from pandas.api import types as pdt
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"ensure_dataframe",
|
|
10
|
+
"is_numeric_or_logical",
|
|
11
|
+
"numeric_logical_columns",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def ensure_dataframe(df: object) -> pd.DataFrame:
|
|
16
|
+
"""Return ``df`` as a DataFrame or raise ``TypeError``.
|
|
17
|
+
|
|
18
|
+
Parameters
|
|
19
|
+
----------
|
|
20
|
+
df
|
|
21
|
+
Object expected to be a :class:`pandas.DataFrame`.
|
|
22
|
+
|
|
23
|
+
Returns
|
|
24
|
+
-------
|
|
25
|
+
pandas.DataFrame
|
|
26
|
+
The validated data frame (a shallow copy is *not* made).
|
|
27
|
+
"""
|
|
28
|
+
if not isinstance(df, pd.DataFrame):
|
|
29
|
+
raise TypeError("df needs to be a pandas DataFrame")
|
|
30
|
+
return df
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def is_numeric_or_logical(series: pd.Series) -> bool:
|
|
34
|
+
"""Return ``True`` if ``series`` is numeric or boolean (R's numeric-or-logical)."""
|
|
35
|
+
return bool(pdt.is_numeric_dtype(series) or pdt.is_bool_dtype(series))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def numeric_logical_columns(df: pd.DataFrame) -> list[str]:
|
|
39
|
+
"""Return the names of columns that are numeric or boolean.
|
|
40
|
+
|
|
41
|
+
Mirrors R's ``df[sapply(df, is.logical) | sapply(df, is.numeric)]``.
|
|
42
|
+
"""
|
|
43
|
+
return [c for c in df.columns if is_numeric_or_logical(df[c])]
|