Resample Irregular Device Power Readings To Fifteen Minute Intervals
Last updated: November 29, 2026
Quick Overview
Using pandas, convert irregular kW readings from many devices into a regular 15-minute series per device, forward-filling short gaps of up to two intervals and labeling each row as measured, filled or missing.
Schneider Electric
November 29, 20260
0
0 solved
Using pandas, convert irregular kW readings from many devices into a regular 15-minute series per device, forward-filling short gaps of up to two intervals and labeling each row as measured, filled or missing.
EcoStruxure gateways report on change or on irregular polling, while analytics and forecasting models want a clean regular grid. This take-home style task checks pandas fluency (groupby, resample, limited fill) and whether you preserve data quality information instead of silently inventing values.
What the Interviewer Expects
- Resamples per device rather than across the whole frame
- Aggregates within a bucket with a stated rule (mean)
- Limits forward fill so long outages stay missing
- Adds an explicit quality column
- Handles duplicate timestamps deterministically
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- Should energy (kWh) be resampled the same way as power (kW)?
- How would you run this on 2 billion rows a day?
- How would you choose between forward fill and interpolation?
- How would downstream models use the quality flag?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
Columns device_id, ts (timezone-aware or UTC), kw as instantaneous power. Buckets are left-labeled 15-minute intervals. Several readings in one bucket are averaged. Gaps up to 30 minutes are fil...
Approach
Sort, group by device, drop duplicate timestamps keeping the last, resample('15min').mean(), then ffill(limit=2). The quality label comes from comparing the series before and after filling....