Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified doc/_build/html/.doctrees/api.doctree
Binary file not shown.
Binary file modified doc/_build/html/.doctrees/environment.pickle
Binary file not shown.
Binary file modified doc/_build/html/.doctrees/getting-started.doctree
Binary file not shown.
Binary file modified doc/_build/html/.doctrees/guides/confidence-intervals.doctree
Binary file not shown.
Binary file modified doc/_build/html/.doctrees/guides/hypothesis-testing.doctree
Binary file not shown.
Binary file modified doc/_build/html/.doctrees/guides/plotting.doctree
Binary file not shown.
Binary file modified doc/_build/html/.doctrees/guides/regression.doctree
Binary file not shown.
Binary file modified doc/_build/html/.doctrees/guides/theory-based.doctree
Binary file not shown.
Binary file modified doc/_build/html/.doctrees/index.doctree
Binary file not shown.
30 changes: 30 additions & 0 deletions doc/_build/html/_modules/moderndive/modeling.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ <h1>Source code for moderndive.modeling</h1><div class="highlight"><pre>
<span class="s2">&quot;get_regression_points&quot;</span><span class="p">,</span>
<span class="s2">&quot;get_regression_summaries&quot;</span><span class="p">,</span>
<span class="s2">&quot;tidy_summary&quot;</span><span class="p">,</span>
<span class="s2">&quot;count_missing&quot;</span><span class="p">,</span>
<span class="p">]</span>


Expand Down Expand Up @@ -442,6 +443,35 @@ <h1>Source code for moderndive.modeling</h1><div class="highlight"><pre>
<span class="p">}</span>
<span class="k">return</span> <span class="n">pl</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">rows</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span></div>



<div class="viewcode-block" id="count_missing">
<a class="viewcode-back" href="../../api.html#moderndive.count_missing">[docs]</a>
<span class="k">def</span><span class="w"> </span><span class="nf">count_missing</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">columns</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">pl</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Count missing (``null``) values in each column.</span>

<span class="sd"> A beginner-friendly alternative to ``df.select(pl.all().is_null().sum())``:</span>
<span class="sd"> it returns a tidy two-column data frame with one row per column</span>
<span class="sd"> (``column``, ``n_missing``), sorted from most to fewest missing values so the</span>
<span class="sd"> columns needing attention surface first.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> data:</span>
<span class="sd"> A polars (or pandas) data frame.</span>
<span class="sd"> columns:</span>
<span class="sd"> Optional list of column names to check; defaults to every column.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">df</span> <span class="o">=</span> <span class="n">data</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">pl</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">)</span> <span class="k">else</span> <span class="n">pl</span><span class="o">.</span><span class="n">from_pandas</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="n">columns</span> <span class="o">=</span> <span class="n">columns</span> <span class="ow">or</span> <span class="n">df</span><span class="o">.</span><span class="n">columns</span>
<span class="k">return</span> <span class="n">pl</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span>
<span class="p">{</span>
<span class="s2">&quot;column&quot;</span><span class="p">:</span> <span class="n">columns</span><span class="p">,</span>
<span class="s2">&quot;n_missing&quot;</span><span class="p">:</span> <span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">df</span><span class="p">[</span><span class="n">col</span><span class="p">]</span><span class="o">.</span><span class="n">null_count</span><span class="p">())</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">],</span>
<span class="p">},</span>
<span class="n">schema</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;column&quot;</span><span class="p">:</span> <span class="n">pl</span><span class="o">.</span><span class="n">Utf8</span><span class="p">,</span> <span class="s2">&quot;n_missing&quot;</span><span class="p">:</span> <span class="n">pl</span><span class="o">.</span><span class="n">Int64</span><span class="p">},</span>
<span class="p">)</span><span class="o">.</span><span class="n">sort</span><span class="p">(</span><span class="s2">&quot;n_missing&quot;</span><span class="p">,</span> <span class="n">descending</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span></div>

</pre></div>
</article>
</div>
Expand Down
3 changes: 2 additions & 1 deletion doc/_build/html/_sources/api.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
:members:
```

## Regression helpers
## Regression & summary helpers

```{eval-rst}
.. autofunction:: moderndive.get_regression_table
Expand All @@ -51,6 +51,7 @@
.. autofunction:: moderndive.get_correlation
.. autofunction:: moderndive.pop_sd
.. autofunction:: moderndive.tidy_summary
.. autofunction:: moderndive.count_missing
```

## Sampling and plots
Expand Down
9 changes: 9 additions & 0 deletions doc/_build/html/_sources/getting-started.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ from moderndive import tidy_summary
tidy_summary(md.load_almonds_sample_100(), columns=["weight"])
```

`count_missing` reports how many `null` values each column has, sorted worst-first
— handy for a quick data-quality check:

```{code-cell} python
from moderndive import count_missing

count_missing(md.load_evals())
```

## The inference pipeline

The core grammar mirrors R `infer`. You build a pipeline and read it like a
Expand Down
28 changes: 25 additions & 3 deletions doc/_build/html/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,8 @@ <h2>Theory-based tests<a class="headerlink" href="#theory-based-tests" title="Li
</dd></dl>

</section>
<section id="regression-helpers">
<h2>Regression helpers<a class="headerlink" href="#regression-helpers" title="Link to this heading">¶</a></h2>
<section id="regression-summary-helpers">
<h2>Regression &amp; summary helpers<a class="headerlink" href="#regression-summary-helpers" title="Link to this heading">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="moderndive.get_regression_table">
<span class="sig-prename descclassname"><span class="pre">moderndive.</span></span><span class="sig-name descname"><span class="pre">get_regression_table</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">model</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">digits</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">conf_level</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.95</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/moderndive/modeling.html#get_regression_table"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#moderndive.get_regression_table" title="Link to this definition">¶</a></dt>
Expand Down Expand Up @@ -916,6 +916,27 @@ <h2>Regression helpers<a class="headerlink" href="#regression-helpers" title="Li
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="moderndive.count_missing">
<span class="sig-prename descclassname"><span class="pre">moderndive.</span></span><span class="sig-name descname"><span class="pre">count_missing</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">columns</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/moderndive/modeling.html#count_missing"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#moderndive.count_missing" title="Link to this definition">¶</a></dt>
<dd><p>Count missing (<code class="docutils literal notranslate"><span class="pre">null</span></code>) values in each column.</p>
<p>A beginner-friendly alternative to <code class="docutils literal notranslate"><span class="pre">df.select(pl.all().is_null().sum())</span></code>:
it returns a tidy two-column data frame with one row per column
(<code class="docutils literal notranslate"><span class="pre">column</span></code>, <code class="docutils literal notranslate"><span class="pre">n_missing</span></code>), sorted from most to fewest missing values so the
columns needing attention surface first.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> – A polars (or pandas) data frame.</p></li>
<li><p><strong>columns</strong> (<span class="sphinx_autodoc_typehints-type"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.14)"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.14)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>] | <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.14)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a></span>) – Optional list of column names to check; defaults to every column.</p></li>
</ul>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p><span class="sphinx_autodoc_typehints-type"><code class="xref py py-class docutils literal notranslate"><span class="pre">DataFrame</span></code></span></p>
</dd>
</dl>
</dd></dl>

</section>
<section id="sampling-and-plots">
<h2>Sampling and plots<a class="headerlink" href="#sampling-and-plots" title="Link to this heading">¶</a></h2>
Expand Down Expand Up @@ -1166,13 +1187,14 @@ <h2>Datasets<a class="headerlink" href="#datasets" title="Link to this heading">
<li><a class="reference internal" href="#moderndive.theory.prop_test_two_sample"><code class="docutils literal notranslate"><span class="pre">prop_test_two_sample()</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#regression-helpers">Regression helpers</a><ul>
<li><a class="reference internal" href="#regression-summary-helpers">Regression &amp; summary helpers</a><ul>
<li><a class="reference internal" href="#moderndive.get_regression_table"><code class="docutils literal notranslate"><span class="pre">get_regression_table()</span></code></a></li>
<li><a class="reference internal" href="#moderndive.get_regression_points"><code class="docutils literal notranslate"><span class="pre">get_regression_points()</span></code></a></li>
<li><a class="reference internal" href="#moderndive.get_regression_summaries"><code class="docutils literal notranslate"><span class="pre">get_regression_summaries()</span></code></a></li>
<li><a class="reference internal" href="#moderndive.get_correlation"><code class="docutils literal notranslate"><span class="pre">get_correlation()</span></code></a></li>
<li><a class="reference internal" href="#moderndive.pop_sd"><code class="docutils literal notranslate"><span class="pre">pop_sd()</span></code></a></li>
<li><a class="reference internal" href="#moderndive.tidy_summary"><code class="docutils literal notranslate"><span class="pre">tidy_summary()</span></code></a></li>
<li><a class="reference internal" href="#moderndive.count_missing"><code class="docutils literal notranslate"><span class="pre">count_missing()</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#sampling-and-plots">Sampling and plots</a><ul>
Expand Down
2 changes: 2 additions & 0 deletions doc/_build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ <h2>C</h2>
<li><a href="api.html#moderndive.chisq_stat">chisq_stat() (in module moderndive)</a>
</li>
<li><a href="api.html#moderndive.chisq_test">chisq_test() (in module moderndive)</a>
</li>
<li><a href="api.html#moderndive.count_missing">count_missing() (in module moderndive)</a>
</li>
</ul></td>
</tr></table>
Expand Down
20 changes: 20 additions & 0 deletions doc/_build/html/getting-started.html
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,26 @@ <h2>A first summary<a class="headerlink" href="#a-first-summary" title="Link to
</style>
<small>shape: (1, 11)</small><table border="1" class="dataframe"><thead><tr><th>column</th><th>n</th><th>group</th><th>type</th><th>min</th><th>Q1</th><th>mean</th><th>median</th><th>Q3</th><th>max</th><th>sd</th></tr><tr><td>str</td><td>i64</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;weight&quot;</td><td>100</td><td>null</td><td>&quot;numeric&quot;</td><td>2.9</td><td>3.4</td><td>3.682</td><td>3.7</td><td>3.9</td><td>4.5</td><td>0.362</td></tr></tbody></table></div></div></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">count_missing</span></code> reports how many <code class="docutils literal notranslate"><span class="pre">null</span></code> values each column has, sorted worst-first
— handy for a quick data-quality check:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">moderndive</span><span class="w"> </span><span class="kn">import</span> <span class="n">count_missing</span>

<span class="n">count_missing</span><span class="p">(</span><span class="n">md</span><span class="o">.</span><span class="n">load_evals</span><span class="p">())</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_html"><div><style>
.dataframe > thead > tr,
.dataframe > tbody > tr {
text-align: right;
white-space: pre-wrap;
}
</style>
<small>shape: (14, 2)</small><table border="1" class="dataframe"><thead><tr><th>column</th><th>n_missing</th></tr><tr><td>str</td><td>i64</td></tr></thead><tbody><tr><td>&quot;ID&quot;</td><td>0</td></tr><tr><td>&quot;prof_ID&quot;</td><td>0</td></tr><tr><td>&quot;score&quot;</td><td>0</td></tr><tr><td>&quot;age&quot;</td><td>0</td></tr><tr><td>&quot;bty_avg&quot;</td><td>0</td></tr><tr><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;pic_outfit&quot;</td><td>0</td></tr><tr><td>&quot;pic_color&quot;</td><td>0</td></tr><tr><td>&quot;cls_did_eval&quot;</td><td>0</td></tr><tr><td>&quot;cls_students&quot;</td><td>0</td></tr><tr><td>&quot;cls_level&quot;</td><td>0</td></tr></tbody></table></div></div></div>
</div>
</section>
<section id="the-inference-pipeline">
<h2>The inference pipeline<a class="headerlink" href="#the-inference-pipeline" title="Link to this heading">¶</a></h2>
Expand Down
2 changes: 1 addition & 1 deletion doc/_build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ <h2>Where to next<a class="headerlink" href="#where-to-next" title="Link to this
<li class="toctree-l2"><a class="reference internal" href="api.html#inference-grammar">Inference grammar</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#getters-and-visualization">Getters and visualization</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#theory-based-tests">Theory-based tests</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#regression-helpers">Regression helpers</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#regression-summary-helpers">Regression &amp; summary helpers</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#sampling-and-plots">Sampling and plots</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#datasets">Datasets</a></li>
</ul>
Expand Down
Binary file modified doc/_build/html/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion doc/_build/html/searchindex.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions doc/_build/jupyter_execute/datasets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "a9e6fc06",
"id": "b560106b",
"metadata": {
"tags": [
"remove-input"
Expand All @@ -19,7 +19,7 @@
},
{
"cell_type": "markdown",
"id": "599ae5ce",
"id": "d4e61ded",
"metadata": {},
"source": [
"# Datasets\n",
Expand All @@ -31,7 +31,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "c158a621",
"id": "79c08466",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -82,7 +82,7 @@
},
{
"cell_type": "markdown",
"id": "37ccb1db",
"id": "9f6c7c7c",
"metadata": {},
"source": [
"## By topic\n",
Expand Down
Loading