← NumPy & Pandas learning path
NumPy & Pandas · Module 8 of 10

Merging and reshaping

Combine tables and change their shape.

📖 Key ideas

  1. pd.merge(a, b, on="id", how="left") joins tables like SQL.
  2. pd.concat stacks DataFrames vertically or horizontally.
  3. melt turns wide data into long data.
  4. pivot turns long data into wide data.
  5. 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