pandas practice problems
17 problems · 0 solved
pandas is the standard Python library for working with tables of data. It lets you filter, group, join and reshape data in a few lines, and it sits at the start of almost every ML project, from exploring logs to building training sets. These problems use data shaped like real LLM product logs, so you practise the operations you will actually need. You will keep only the latest subscription record per user, summarise API calls per model with named groupby aggregations, join usage to a price table and fill missing prices with a default, pivot repeated eval runs into a model by benchmark table, resample a request log to hourly traffic with zero-filled gaps, and compute a three-day calendar rolling error rate per model when some days are missing. Start with the Easy problems on deduplication and groupby. Then do the join and pivot problems, and finish with resampling and time-based rolling windows, where date handling gets tricky. Many interviews for data and ML roles include a live pandas task, and being fluent here saves a lot of time when you need quick answers from messy data at work.
Easy 5
Medium 7
- Join usage to a price table and fill missing prices with a default
- Pivot repeated eval runs into a model by benchmark score table
- Audit eval coverage with an outer merge and the indicator column
- Fill missing latencies with each model's median and a global fallback
- Forward fill each user's plan in time order without leaking across users
- Price API requests with marginal token tiers using vectorized NumPy instead of apply
- Add each request's share of its user's tokens and its rank with groupby transform
Hard 5
- Compute a 3-day calendar rolling error rate per model with gaps in the dataPro
- Resample a request log to hourly traffic, filling empty hours with zerosPro
- Flag metric spikes with a rolling z-score of the previous values per modelPro
- Build a monthly cohort retention matrix with pandasPro
- Price each API call with the rate in effect at that time using merge_asofPro