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 (Aldi
, Walmart
, Costco
) into values of one column (store
).
Google Colab notebook of the code above.
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 (Aldi
, Walmart
, Costco
) into values of one column (store
).
Google Colab notebook of the code above.