Manipulate time-series with Pandas groupby
AmazonSoftware Engineer · Technical ScreenLast updated
This question evaluates proficiency in time-series data manipulation, including timezone-aware datetime parsing and DST handling, groupby and rolling-window aggregations, resampling to fill calendar gaps, and user-level retention and DAU calculations using idiomatic, vectorized Pandas or SQL operations.
Given a DataFrame events(user_id, event_type, ts_utc, revenue):
- Parse ts_utc as timezone-aware, convert to America/Los_Angeles, and handle DST transitions.
- Compute daily active users (DAU) and a 7-day moving average.
- For each user and event_type, compute a 7-day rolling count.
- Produce weekly retention: the number and rate of users active in week w who return in week w+1.
- Resample to fill missing calendar dates with zeros. Provide idiomatic, vectorized Pandas code (no explicit Python loops).
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.