Skip to content

Add materials for the Python statistics fundamentals tutorial - #827

Merged
martin-martin merged 1 commit into
masterfrom
add-python-statistics-materials
Sep 14, 2026
Merged

martin-martin merged 1 commit into
masterfrom
add-python-statistics-materials

Conversation

@martin-martin

Copy link
Copy Markdown
Contributor

Adds a companion folder for Python Statistics Fundamentals: How to Describe Your Data, which shipped in 2019 without one.

This came out of the tutorial's maintenance pass (card 203), which re-ran the whole article on the current stack and repinned it. The article half is booked to publish on 2026-09-19; this is the code half, so the tutorial can offer a real download instead of the unrelated Matplotlib opt-in it carries today.

What's here

The tutorial teaches in the REPL. Each of its sections becomes a script you can run end to end, with the example data shared in datasets.py so a reader can swap in their own numbers in one place.

File Tutorial section
datasets.py The example data every other script imports
central_tendency.py Measures of Central Tendency
variability.py Measures of Variability
summary_statistics.py Summary of Descriptive Statistics
correlation.py Measures of Correlation Between Pairs of Data
two_dimensional_data.py Working With 2D Data: Axes
dataframes.py Working With 2D Data: DataFrames
plot_*.py (6 files) Visualizing Data: box, histogram, pie, bar, x-y, heatmap

Verification

Built a virtualenv on the tutorial's newly pinned stack — Python 3.14.6, NumPy 2.5.3, SciPy 1.18.1, pandas 3.0.5, Matplotlib 3.11.2 — and ran every script rather than eyeballing them. All 13 run clean, plots included. ruff format --check and ruff check both pass under the repo's pinned ruff 0.14.1.

The run also independently corroborated three of the article fixes from the same maintenance pass, reproduced here from scratch rather than copied across:

  • the pure-Python vs NumPy variance split, 123.2 against 123.19999999999999
  • the full LinregressResult repr, including the intercept_stderr=np.float64(0.4234100995002589) field SciPy added
  • np.ptp(z_with_nan) returning nan rather than 46.0, since pandas dropped Series.ptp

Notes for review

  • Code uses double quotes throughout rather than the article's single quotes, following the house style preference that preflight flags on the article itself.
  • The REPL sessions are reshaped into named functions rather than transcribed block for block, so from central_tendency import harmonic_mean works on its own. Happy to flatten them if you'd rather they mirror the article line by line.
  • constraints.txt pins the verified versions; requirements.txt is left unpinned so the folder keeps working as the stack moves.

Reviewed by @martin-martin.

🤖 Generated with Claude Code

Python Statistics Fundamentals: How to Describe Your Data shipped without
a companion folder. Its 2026 maintenance pass re-ran the tutorial on the
current stack, so add the code here in runnable form.

The tutorial teaches in the REPL. Each of its sections becomes a script
that runs end to end, with the example data shared in datasets.py so a
reader can swap in their own numbers in one place.

Verified on the tutorial's pinned stack (Python 3.14.6, NumPy 2.5.3,
SciPy 1.18.1, pandas 3.0.5, Matplotlib 3.11.2): all 13 scripts run, and
the values match the tutorial, including the NumPy 2 scalar reprs and the
linregress result.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@martin-martin
martin-martin merged commit ee3b947 into master Sep 14, 2026
1 check passed
@martin-martin
martin-martin deleted the add-python-statistics-materials branch September 14, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants