pandas.melt: Unpivot a DataFrame

If you want to unpivot a DataFrame from wide to long format, use pandas.melt.

For example, you can use pandas.melt to turn multiple columns (AldiWalmart, Costco) into values of one column (store).

Google Colab notebook of the code above.

Link to my previous tips on pandas.

Scroll to Top