Pivot and Melt in Python
From the Pandas cheat sheet ยท Reshape Data ยท verified Aug 2026
Pivot and Melt
Reshape long data to wide form and back.
python
wide = df.pivot(index="date", columns="metric", values="value")๐ pivot requires unique index-column pairs
๐ก pivot_table aggregates duplicate pairs
๐ melt converts wide columns into row values
๐ฏ Use long form for most grouped analysis
pivotmeltreshape
Continue with Pandas
Save the full cheat sheet or work through every related task.