Pandas
Read, clean, reshape, join, and analyze tabular data. Avoid the silent bugs that bite everyone. Learn the patterns that scale to millions of rows.
- Chapter 01
Getting Started
5 lessons - 01 Series A Series is a 1D labeled array — the building block of every DataFrame, and the source of pandas' most magical (and most confusing) behavior.
- 02 DataFrame basics The single most important class in the Python data stack. Create one, inspect it, and select from it without surprises.
- 03 Reading data read_csv, read_parquet, read_json, read_sql — and the half-dozen arguments that turn a "this won't parse" file into a clean DataFrame.
- 04 Selection: loc vs iloc The single most-asked pandas question, answered with rules you can apply without thinking. Plus the chained-indexing trap that ruins everyone's aft…
- 05 Missing data NaN, None, pd.NA, and the three different ways your data can be "missing." How to detect, drop, fill, and interpolate it without lying to yourself.
- Chapter 02
Transforming Data
5 lessons - 06 GroupBy The one pandas pattern you'll use in 80% of analytical scripts. Per-user metrics, per-day rollups, per-segment stats — it's all groupby.
- 07 Merge & join SQL joins, but in pandas. The arguments that turn a "looks right" merge into one that's verified row-by-row, with no quiet data duplication.
- 08 pivot, melt, stack Turn long event logs into wide feature tables and back. The four verbs that move data between "tidy" and "human-readable" shapes.
- 09 Time series DatetimeIndex, resampling, rolling windows, and the .dt accessor — the toolkit for daily, weekly, or minute-by-minute aggregations.
- 10 Method chaining Chain DataFrame operations into one fluent pipeline. `.pipe`, `.assign`, `.query` — and the one place where breaking the chain still pays.
- Chapter 03
Performance & Pitfalls
3 lessons - 11 Memory optimization Profile real memory usage with `info(memory_usage='deep')`, then shrink with downcasting, categoricals, and smarter `read_csv` calls.
- 12 SettingWithCopyWarning — fixed The most misread warning in Pandas. Why it happens, when it's a real bug, and the one-shot `.loc` rule that makes it go away.
- 13 When to switch to Polars A Rust-powered DataFrame library with lazy execution, native parallelism, and a query language that reads like SQL. When to switch, and how the syn…
- End of section 0 / 13 complete
Make it stick — pass every quiz.
Each lesson has a short quiz at the bottom. Passing the quiz is what marks the lesson complete and counts toward your certificate.
Pandas — frequently asked questions
Straight answers to the questions people ask most about pandas.
What's the difference between loc and iloc in Pandas?
`loc` selects by label (index and column names); `iloc` selects by integer position. Use `loc` when you know the row index or column name, and `iloc` when you want the Nth row or column regardless of its label.
How do I avoid the SettingWithCopyWarning?
That warning means you may be assigning to a copy of a slice, so the change might not stick. Do the selection and assignment in a single `.loc` call — e.g. `df.loc[df.x > 0, 'y'] = 1` — or take an explicit `.copy()` first if you intend to work on a separate frame.
When should I use apply versus a vectorised operation?
Prefer vectorised operations and built-in methods — they run in optimised C and are far faster than `apply`, which loops in Python. Use `apply` only for genuinely custom row/column logic that can't be expressed with vectorised functions.
What's the difference between merge, join, and concat?
`merge` (and the similar `join`) combine frames by matching key columns, like a SQL join. `concat` stacks frames along an axis — rows on top of each other or columns side by side — without matching keys. Use merge for relational joins and concat for appending or aligning by index.
Why did my groupby explode the number of rows?
That usually happens when you merge before aggregating — a one-to-many join multiplies rows, and a later sum double-counts. Aggregate to the right grain first, or confirm your join keys are unique, before combining tables.