Skip to content

Master cheat sheet

The master cheat sheet is the course in reference form. It has 57 pages in eight groups. Each page has:

  • a “Quick lookup” table (I want to… → use…);
  • dense tables and compact code with one-line comments;
  • a “Gotchas” section;
  • links to the lessons that teach the topic in depth.

The Python and OOP pages are general-purpose: use them for web, scripting and automation work too. The module cheat sheets (one per module, linked from each lesson) go deeper on a single topic.

All code on these pages runs as shown, and every output is real.

I want to… Use…
format numbers in a report (1,234.50, 12.5%) Strings and f-string formatting
pick a list, dict, set, deque or DataFrame Which data structure
write a decorator or a context manager Decorators and context managers
parse text with a regular expression Regular expressions
add type hints that mypy accepts Type hints
test a function with pytest fixtures pytest
set up a project with uv, ruff and pyproject Tooling
avoid the classic Python traps Idioms and gotchas
make my object work with len(), in or + Dunder methods
choose dataclass, NamedTuple, TypedDict or pydantic Data containers
group, pivot or merge tables pandas
run fast queries on large files Polars and SQL and DuckDB
choose a chart for my question Which chart
choose a statistical test Which statistical test
check Big-O, tries, Union-Find, graphs or DP patterns Complexity & structures and Algorithm patterns
look up QR, SVD, Jacobians, Hessians or optimizers Linear algebra and Calculus & optimization
run Bayesian A/B tests, KL drift, IPW or GLMs Probability & Bayesian and Causal inference & GLMs
build a leakage-safe preprocessing pipeline scikit-learn API and Preprocessing
choose an ML algorithm Which ML algorithm
choose a metric Which metric and Metrics
choose a cross-validation strategy Which CV strategy
tune XGBoost or LightGBM Gradient boosting libraries
forecast a time series Time series
train a neural network PyTorch
explain a model’s predictions Interpretability
serve a model behind an API Deployment and MLOps basics
follow the whole ML process step by step ML workflow
print everything or save it as a PDF Printable cheat sheet
  1. Search first. The site search (top of the page) indexes every table row.
  2. Start from the lookup table of a page. It points to the right section.
  3. Copy a snippet, then run it on the course data in your own project folder.
  4. When a row is not enough, follow “Learn more” to the lesson that teaches it.
  • Library versions matter. The pages match the versions pinned in the course requirements.txt (pandas 3, NumPy 2, scikit-learn 1.9, PyTorch 2.15). Older tutorials online often use removed or deprecated APIs.
  • A cheat sheet shows the common path. Check edge cases (missing values, empty inputs, ties) in your own data before you rely on a snippet.
  • Several pages repeat the same rule because it matters everywhere: fit preprocessing on training data only, and read the test set once.