Pandas Interview Prep
5 min read Quiz at the end
Key Pandas interview topics: loc vs iloc, groupby+transform, merge vs concat, pivot vs melt, inplace.
Pandas Interview Topics
- Series vs DataFrame — Series is 1D labelled array; DataFrame is 2D labelled table of Series
- loc vs iloc — loc uses labels; iloc uses integer positions
- apply vs vectorised — always prefer vectorised ops (df[col] + x); apply is slower
- groupby + transform — transform returns same-index result to merge stats back into original df
- merge vs join vs concat — merge/join = SQL JOIN on columns; concat = SQL UNION (rows) or cbind (cols)
- pivot vs melt — pivot: long to wide; melt: wide to long
- inplace=True — modifies df in place; without it returns a copy
- category dtype — use for low-cardinality string columns to save memory and speed up groupby
- resample — time series downsampling/upsampling (daily to monthly)
- chaining methods — df.query().groupby().agg().reset_index() for readable pipelines
Topic Quiz · 1 questions
Test your understanding before moving on
1. What does df.pivot_table differ from df.pivot?
💡 pivot_table is more flexible — it aggregates (mean, sum) and handles duplicate values automatically.