← NumPy & Pandas learning pathNumPy & Pandas · Module 8 of 10
Merging and reshaping
Combine tables and change their shape.
📖 Key ideas
- pd.merge(a, b, on="id", how="left") joins tables like SQL.
- pd.concat stacks DataFrames vertically or horizontally.
- melt turns wide data into long data.
- pivot turns long data into wide data.
- Check row counts after merges to catch duplicates.
💡 Real-life example: Merging is matching admission forms with fee receipts using the roll number.
mergeSQL-like join
concatStacks DataFrames
meltWide to long format
pivotLong to wide format