Python
#47

Downsample and Aggregate Time Series with resample() in Pandas

Medium
Interview Question #47

Given a high-frequency transaction log indexed by Datetime, downsample the data into calendar month-end buckets ('ME') and compute total monthly revenue and transaction count.

Input Table: txns
3 rows preview
timestampamount
2026-01-05 10:00:00500
2026-01-20 14:00:00750
2026-02-02 09:00:001200
Expected Output Structure2 rows
timestamptotal_revenuetxn_count
2026-01-3112502
2026-02-2812001
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

Python 3.10 (Pandas)
Environment Ready

Click "Run & Test" to execute your Pandas code against the test assertions.

Chat with us