Wide to long with melt
A pandas exercise from Pandasdrill. Solve it with a Python editor in your browser running real pandas, and it is checked the moment you submit.
The task
Turn `wide` (one column per quarter) into a long table with the columns `store`, `quarter` and `sales`.
What this exercise teaches
melt unpivots: every quarter column becomes rows, with the old column name in quarter and the cell in sales. Rows come out quarter by quarter, which is the order checked here.
A hint if you get stuck
melt keeps the id_vars columns and turns the other columns into name and value pairs. var_name and value_name set the new column names.
This exercise is part of Pro
Pro unlocks all 45 exercises, with worked solutions and progress saved to your account. The free exercises work without an account.
You create a free account first, so Pro is attached to it.
Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.