Add materials for the Python statistics fundamentals tutorial - #827
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.pyso a reader can swap in their own numbers in one place.datasets.pycentral_tendency.pyvariability.pysummary_statistics.pycorrelation.pytwo_dimensional_data.pydataframes.pyplot_*.py(6 files)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 --checkandruff checkboth 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:
123.2against123.19999999999999LinregressResultrepr, including theintercept_stderr=np.float64(0.4234100995002589)field SciPy addednp.ptp(z_with_nan)returningnanrather than46.0, since pandas droppedSeries.ptpNotes for review
from central_tendency import harmonic_meanworks on its own. Happy to flatten them if you'd rather they mirror the article line by line.constraints.txtpins the verified versions;requirements.txtis left unpinned so the folder keeps working as the stack moves.Reviewed by @martin-martin.
🤖 Generated with Claude Code