diff --git a/README.md b/README.md index f7e6698..24e2867 100644 --- a/README.md +++ b/README.md @@ -41,10 +41,11 @@ pip install git+https://github.com/moderndive/moderndive-python `engine="plotnine"` — same code, your choice of output. - **Theory-based wrapper tests**: `t_test`, `prop_test`, `chisq_test`, `t_stat`, `chisq_stat`, plus the `moderndive.theory` module. -- **Regression helpers** mirroring R `moderndive`: `get_regression_table`, +- **Regression & summary helpers** mirroring R `moderndive`: `get_regression_table`, `get_regression_points`, `get_regression_summaries`, `get_correlation`, - `pop_sd`, `tidy_summary` (built on `statsmodels`, returning `polars` frames), - plus the model plots `gg_parallel_slopes` / `geom_parallel_slopes` and + `pop_sd`, `tidy_summary`, `count_missing` (built on `statsmodels` where + relevant, returning `polars` frames), plus the model plots + `gg_parallel_slopes` / `geom_parallel_slopes` and `gg_categorical_model` / `geom_categorical_model`, and `pairplot` (the `GGally::ggpairs` analog). - **Sampling**: `rep_slice_sample` / `rep_sample_n` for sampling-distribution diff --git a/doc/_build/html/.doctrees/api.doctree b/doc/_build/html/.doctrees/api.doctree index 1c11711..4ee6fb2 100644 Binary files a/doc/_build/html/.doctrees/api.doctree and b/doc/_build/html/.doctrees/api.doctree differ diff --git a/doc/_build/html/.doctrees/environment.pickle b/doc/_build/html/.doctrees/environment.pickle index f403092..32d544f 100644 Binary files a/doc/_build/html/.doctrees/environment.pickle and b/doc/_build/html/.doctrees/environment.pickle differ diff --git a/doc/_build/html/.doctrees/getting-started.doctree b/doc/_build/html/.doctrees/getting-started.doctree index 04b4750..86761dc 100644 Binary files a/doc/_build/html/.doctrees/getting-started.doctree and b/doc/_build/html/.doctrees/getting-started.doctree differ diff --git a/doc/_build/html/.doctrees/guides/confidence-intervals.doctree b/doc/_build/html/.doctrees/guides/confidence-intervals.doctree index 43befad..09c464e 100644 Binary files a/doc/_build/html/.doctrees/guides/confidence-intervals.doctree and b/doc/_build/html/.doctrees/guides/confidence-intervals.doctree differ diff --git a/doc/_build/html/.doctrees/guides/hypothesis-testing.doctree b/doc/_build/html/.doctrees/guides/hypothesis-testing.doctree index 553050f..efd13ea 100644 Binary files a/doc/_build/html/.doctrees/guides/hypothesis-testing.doctree and b/doc/_build/html/.doctrees/guides/hypothesis-testing.doctree differ diff --git a/doc/_build/html/.doctrees/guides/plotting.doctree b/doc/_build/html/.doctrees/guides/plotting.doctree index 7c5a602..5b08f33 100644 Binary files a/doc/_build/html/.doctrees/guides/plotting.doctree and b/doc/_build/html/.doctrees/guides/plotting.doctree differ diff --git a/doc/_build/html/.doctrees/guides/regression.doctree b/doc/_build/html/.doctrees/guides/regression.doctree index c0bdb8c..97b30c5 100644 Binary files a/doc/_build/html/.doctrees/guides/regression.doctree and b/doc/_build/html/.doctrees/guides/regression.doctree differ diff --git a/doc/_build/html/.doctrees/guides/theory-based.doctree b/doc/_build/html/.doctrees/guides/theory-based.doctree index 6821e99..98e6f69 100644 Binary files a/doc/_build/html/.doctrees/guides/theory-based.doctree and b/doc/_build/html/.doctrees/guides/theory-based.doctree differ diff --git a/doc/_build/html/.doctrees/index.doctree b/doc/_build/html/.doctrees/index.doctree index 8811216..73bb499 100644 Binary files a/doc/_build/html/.doctrees/index.doctree and b/doc/_build/html/.doctrees/index.doctree differ diff --git a/doc/_build/html/_modules/moderndive/modeling.html b/doc/_build/html/_modules/moderndive/modeling.html index 482acb1..34f9394 100644 --- a/doc/_build/html/_modules/moderndive/modeling.html +++ b/doc/_build/html/_modules/moderndive/modeling.html @@ -269,6 +269,7 @@
"get_regression_points",
"get_regression_summaries",
"tidy_summary",
+ "count_missing",
]
@@ -442,6 +443,35 @@ Source code for moderndive.modeling
}
return pl.DataFrame(rows, schema=schema)
+
+
+
+[docs]
+def count_missing(data, columns: list[str] | None = None) -> pl.DataFrame:
+ """Count missing (``null``) values in each column.
+
+ A beginner-friendly alternative to ``df.select(pl.all().is_null().sum())``:
+ it returns a tidy two-column data frame with one row per column
+ (``column``, ``n_missing``), sorted from most to fewest missing values so the
+ columns needing attention surface first.
+
+ Parameters
+ ----------
+ data:
+ A polars (or pandas) data frame.
+ columns:
+ Optional list of column names to check; defaults to every column.
+ """
+ df = data if isinstance(data, pl.DataFrame) else pl.from_pandas(data)
+ columns = columns or df.columns
+ return pl.DataFrame(
+ {
+ "column": columns,
+ "n_missing": [int(df[col].null_count()) for col in columns],
+ },
+ schema={"column": pl.Utf8, "n_missing": pl.Int64},
+ ).sort("n_missing", descending=True)
+
Count missing (null) values in each column.
A beginner-friendly alternative to df.select(pl.all().is_null().sum()):
+it returns a tidy two-column data frame with one row per column
+(column, n_missing), sorted from most to fewest missing values so the
+columns needing attention surface first.
prop_test_two_sample()count_missing reports how many null values each column has, sorted worst-first
+— handy for a quick data-quality check:
from moderndive import count_missing
+
+count_missing(md.load_evals())
+| column | n_missing |
|---|---|
| str | i64 |
| "ID" | 0 |
| "prof_ID" | 0 |
| "score" | 0 |
| "age" | 0 |
| "bty_avg" | 0 |
| … | … |
| "pic_outfit" | 0 |
| "pic_color" | 0 |
| "cls_did_eval" | 0 |
| "cls_students" | 0 |
| "cls_level" | 0 |
| column | n_missing |
|---|---|
| str | i64 |
| "ID" | 0 |
| "prof_ID" | 0 |
| "score" | 0 |
| "age" | 0 |
| "bty_avg" | 0 |
| … | … |
| "pic_outfit" | 0 |
| "pic_color" | 0 |
| "cls_did_eval" | 0 |
| "cls_students" | 0 |
| "cls_level" | 0 |