Files

9 lines
806 B
Markdown
Raw Permalink Normal View History

2026-06-15 15:26:18 +02:00
# Reshaping
2026-06-16 13:12:17 +02:00
Reshaping transforms the structure of a DataFrame without changing its data. `pivot()` and `pivot_table()` convert long-format data to wide format. `melt()` does the reverse, converting wide to long. `stack()` and `unstack()` move index levels to columns or vice versa. Reshaping is often needed to prepare data for specific visualizations or models.
Visit the following resources to learn more:
- [@official@Reshaping and pivot tables](https://pandas.pydata.org/docs/user_guide/reshaping.html)
- [@article@Reshaping a Pandas Dataframe: Long-to-Wide and Vice Versa](https://towardsdatascience.com/reshaping-a-pandas-dataframe-long-to-wide-and-vice-versa-517c7f0995ad/)
- [@video@Pandas - Reshape Dataframe](https://www.youtube.com/watch?v=oY62o-tBHF4&list=PL6icxsSf2sRe2qqFmtZwU_VKChEChzhEP)