Build Daily Peak-Share Usage Profiles From Half-Hourly Reads

Last updated: November 29, 2026

Quick Overview

Using pandas, turn a frame of half-hourly reads (account_id, UTC interval_start, kwh) into one row per account per UK local day with total kWh, kWh used in the 16:00 to 19:00 peak window, and the peak share.

Fuse Energy
Data Manipulation (SQL/Python)
Data Scientist
Fuse Energy
November 29, 2026
Data Scientist
Take-home Project
Data Manipulation (SQL/Python)
Easy

0

0

0 solved


Using pandas, turn a frame of half-hourly reads (account_id, UTC interval_start, kwh) into one row per account per UK local day with total kWh, kWh used in the 16:00 to 19:00 peak window, and the peak share.

Time-of-use tariffs only pay off for customers who can move usage out of the evening peak, so Fuse's data team would want each household's peak share to target offers and measure shifting. The exercise checks time zone conversion, dedup of re-delivered reads and safe division.

What the Interviewer Expects
  • Convert UTC to Europe/London before deriving day and hour
  • Deduplicate on (account, interval) keeping the latest delivery
  • Use a half-open peak window [16:00, 19:00)
  • Avoid division by zero for zero-consumption days
  • Report slot counts so incomplete days are visible
Key Topics to Cover
pandas groupby
Time zones
Deduplication
Conditional aggregation
Load profiles
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you exclude days with fewer than 46 valid reads?
  • How would you compute this for 300k accounts over a year without running out of memory?
  • How would you turn peak share into a segment for a time-of-use tariff offer?
  • What changes for gas, which has no strong evening peak pricing?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

Columns: account_id, interval_start (UTC string or timestamp, the start of each half hour), kwh (may be null). Re-deliveries can duplicate an interval; the later row in the frame is the newer de...

Approach

Drop nulls, dedupe keeping the last row per key, convert to Europe/London, derive day and minutes since midnight. Create a peak_kwh column that equals kwh inside [16:00, 19:00) and 0 otherwise...


Submit Your Answer
Markdown supported

Related Questions