Ravindra BagaleCourses & study guides

11. Reshape and Wide/Long Data

11.4 stack / unstack (Brief)

s = pt.stack()          # Series with MultiIndex
back = s.unstack()      # toward wide again

Useful when you already have a MultiIndex from groupby.

Practice task

Melt wide, then use pivot_table to get month as rows and city as columns (transpose the usual view). Which city-month is highest GMV?

Thodkyaat sangaycha tar (quick recap)

  • Long form for analysis; wide for human grids
  • melt ↔ pivot_table are the daily reshape pair
  • Prefer pivot_table when duplicates need aggregating

Samajla ka? Aata pudhe jaauya Exploratory Data Analysis (EDA).