Rearrange Products Table
wide has columns product_id, store1, store2 and store3, where each store column is that product's price in the store. Return a "long" DataFrame with the columns product_id, store (the column name, like "store2") and price: one row per product and store, ordered by product_id and then by store.
Example 1
wide {"product_id":[7],"store1":[10],"store2":[20],"store3":[30]}
returns {"columns":["product_id","store","price"],"rows":[[7,"store1",10],[7,"store2",20],[7,"store3",30]]}
Product 7 turns into three rows.
Constraints
- No price is missing
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More pandas problems
- Record ReadingsMedium
- Reformat Department TableMedium
- Revenue per ProductMedium
- Rising TemperatureMedium
- Salespeople Without Red OrdersMedium
- Three in a RowMedium
- Top Earners per DepartmentMedium
- Two Best per TeamMedium