Pandas data engineering interview problem. Difficulty: beginner. Pattern: Window Functions. About 12 minutes. Part of the Pro drill bank.
7-day rolling average and 30-day rolling sum on a short series. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
Sort by date. Return date, value, and both rolling columns. Assign result.
Input: daily values Output: date | value | rolling_avg_7d | rolling_sum_30d 2024-01-01 | 1.0 | 1.0 | 1.0 2024-01-02 | 2.0 | 1.5 | 3.0 2024-01-03 | 3.0 | 2.0 | 6.0 2024-01-04 | 4.0 | 2.5 | 10.0 2024-01-05 | 5.0 | 3.0 | 15.0 2024-01-06 | 6.0 | 3.5 | 21.0 Short fixture never fills a full 7/30 window; min_periods=1 still progresses.
Topics: lakebench, pandas, rolling.
More interview problems · All interview problems · Learn data engineering
Interview-style drill: 7-day rolling average and 30-day rolling sum on a short series.
Sort by `date`. Add `rolling_avg_7d` = rolling mean of `value` with window 7 and `rolling_sum_30d` with window 30, both `min_periods=1`. Return `date`, `value`, and both rolling columns. Assign `result`.