Pandas interview question: rolling 7-day revenue

EasyRolling aggregates

Problem

Shared data rules

For each city and day in Sep 7–27, 2026, find revenue over the last 7 days.

Formula

Example

Input: orders
order_idcreated_atstatuscityamount_usdRow note
1012026-09-02 12:00deliveredBoston20
1022026-09-03 18:20deliveredBoston40
1032026-09-04 09:30deliveredBoston30
1042026-09-06 11:10deliveredBoston50← no orders on Sep 5
1052026-09-07 19:30deliveredBoston20
1062026-09-08 13:00deliveredBoston40
1072026-09-09 10:15deliveredBoston30
Output (excerpt)
citywindow_endrevenue_7d
Boston2026-09-07160
Boston2026-09-08200
Boston2026-09-09210

Windows for Sep 7–9. The Sep 7 window covers Sep 1–7, so orders from before Sep 7 count too: 20 + 40 + 30 + 50 + 20 = $160.

Solve it free

Your code runs on real pandas in your browser. No sign-up needed.

Skills it tests

More interview questions

All questions