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.
Files changed (80) hide show
  1. expdpy/__init__.py +147 -0
  2. expdpy/_assets/favicon.png +0 -0
  3. expdpy/_assets/favicon.svg +12 -0
  4. expdpy/_assets/logo-navbar.svg +14 -0
  5. expdpy/_assets/logo.png +0 -0
  6. expdpy/_assets/logo.svg +14 -0
  7. expdpy/_corr.py +80 -0
  8. expdpy/_estimation/__init__.py +38 -0
  9. expdpy/_estimation/_capture.py +26 -0
  10. expdpy/_estimation/_fit.py +56 -0
  11. expdpy/_estimation/_formula.py +50 -0
  12. expdpy/_estimation/_results.py +30 -0
  13. expdpy/_estimation/_spec.py +112 -0
  14. expdpy/_estimation/_tidy.py +35 -0
  15. expdpy/_estimation/_vcov.py +52 -0
  16. expdpy/_theme.py +201 -0
  17. expdpy/_types.py +505 -0
  18. expdpy/_validation.py +43 -0
  19. expdpy/app/__init__.py +766 -0
  20. expdpy/app/_components.py +282 -0
  21. expdpy/app/_config_io.py +63 -0
  22. expdpy/app/_export_nb.py +234 -0
  23. expdpy/app/_sample.py +124 -0
  24. expdpy/app/_state.py +102 -0
  25. expdpy/app/_udv.py +179 -0
  26. expdpy/app/_upload.py +43 -0
  27. expdpy/app/_varcat.py +100 -0
  28. expdpy/by_group.py +313 -0
  29. expdpy/coefplot.py +236 -0
  30. expdpy/correlation.py +152 -0
  31. expdpy/data/__init__.py +103 -0
  32. expdpy/data/expdpy_config_kuznets.json +54 -0
  33. expdpy/data/gapminder.parquet +0 -0
  34. expdpy/data/gapminder_data_def.parquet +0 -0
  35. expdpy/data/kuznets.parquet +0 -0
  36. expdpy/data/kuznets_data_def.parquet +0 -0
  37. expdpy/data/staggered_did.parquet +0 -0
  38. expdpy/data/staggered_did_data_def.parquet +0 -0
  39. expdpy/did.py +405 -0
  40. expdpy/distributions.py +130 -0
  41. expdpy/estimation.py +282 -0
  42. expdpy/fwl.py +284 -0
  43. expdpy/inference.py +92 -0
  44. expdpy/missing.py +117 -0
  45. expdpy/outliers.py +180 -0
  46. expdpy/panel_models.py +244 -0
  47. expdpy/pedagogy/__init__.py +43 -0
  48. expdpy/pedagogy/_format.py +88 -0
  49. expdpy/pedagogy/_interpret.py +355 -0
  50. expdpy/pedagogy/_mixin.py +44 -0
  51. expdpy/pedagogy/_registry.py +121 -0
  52. expdpy/pedagogy/_text/__init__.py +11 -0
  53. expdpy/pedagogy/_text/causal.py +65 -0
  54. expdpy/pedagogy/_text/correlation.py +77 -0
  55. expdpy/pedagogy/_text/outliers.py +53 -0
  56. expdpy/pedagogy/_text/regression.py +257 -0
  57. expdpy/pedagogy/_text/tables.py +51 -0
  58. expdpy/postestimation.py +202 -0
  59. expdpy/py.typed +0 -0
  60. expdpy/regression.py +201 -0
  61. expdpy/sandbox.py +307 -0
  62. expdpy/scatter.py +207 -0
  63. expdpy/streamlit_app/__init__.py +106 -0
  64. expdpy/streamlit_app/_context.py +99 -0
  65. expdpy/streamlit_app/_entry.py +57 -0
  66. expdpy/streamlit_app/_handoff.py +149 -0
  67. expdpy/streamlit_app/_launcher.py +103 -0
  68. expdpy/streamlit_app/_pages.py +424 -0
  69. expdpy/streamlit_app/_pipeline.py +99 -0
  70. expdpy/streamlit_app/_render.py +221 -0
  71. expdpy/streamlit_app/_run.py +9 -0
  72. expdpy/streamlit_app/_sidebar.py +258 -0
  73. expdpy/streamlit_app/_widgets.py +95 -0
  74. expdpy/tables.py +348 -0
  75. expdpy/trends.py +263 -0
  76. expdpy-0.2.0.dist-info/METADATA +203 -0
  77. expdpy-0.2.0.dist-info/RECORD +80 -0
  78. expdpy-0.2.0.dist-info/WHEEL +4 -0
  79. expdpy-0.2.0.dist-info/entry_points.txt +2 -0
  80. 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])]