Pandas data engineering interview problem. Difficulty: beginner. Pattern: Pivot. About 12 minutes. Free to practice.
Pivot long product amounts to wide columns per date. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
Pivot long so dates are rows, products are columns, values are summed amount, missing cells 0. Reset index so date is a column. Assign result.
Input: long sales Output: date | A | B | C 2024-01-01 | 10.0 | 5.0 | 0.0 2024-01-02 | 7.0 | 0.0 | 3.0 Missing product/date pairs become 0.
Topics: lakebench, pandas, pivot_table.
More interview problems · All interview problems · Learn data engineering
Interview-style drill: Pivot long product amounts to wide columns per date.
Pivot `long` so dates are rows, products are columns, values are summed `amount`, missing cells 0. Reset index so `date` is a column. Assign `result`.