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: df
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-31 00:00:0012502
2026-02-28 00:00:0012001
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

Starting the real Python + pandas runtime (one-time download)…

Chat with us