Build a Weekday by Local Hour Order Heatmap per Marketplace
Last updated: November 29, 2026
Quick Overview
Order timestamps are stored in UTC across Amazon marketplaces. Using pandas, build a 7 by 24 table of order counts by weekday and local hour for a given marketplace, converting to that marketplace's timezone correctly including daylight saving changes.
Amazon
November 29, 20260
0
0 solved
Order timestamps are stored in UTC across Amazon marketplaces. Using pandas, build a 7 by 24 table of order counts by weekday and local hour for a given marketplace, converting to that marketplace's timezone correctly including daylight saving changes.
Staffing for customer service, fulfillment wave planning and deal timing at Amazon all depend on when customers actually shop in local time. Interviewers use this to see whether candidates convert timezones with tz-aware types instead of subtracting fixed offsets, and whether the output grid is complete.
What the Interviewer Expects
- Parse timestamps as UTC-aware before converting
- Use tz_convert with an IANA zone so DST is handled
- Derive weekday and hour after conversion, not before
- Reindex to the full 7 x 24 grid with zeros
- Label rows and columns so the table is readable
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
- How would you build one table for all marketplaces at once when each has its own timezone?
- The US spans several timezones; what would you use for a US marketplace heatmap?
- How would you normalize counts so weeks with Prime Day do not dominate?
- What happens to the 1 a.m. hour on the day clocks fall back?
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
orders(order_id, order_ts_utc, marketplace). Timestamps are ISO strings in UTC.- Each marketplace maps to one representative IANA timezone; for the US I would confirm with the interviewer whether...
Approach
- Filter to the marketplace.
pd.to_datetime(..., utc=True)then.dt.tz_convert(tz). Using a fixed offset like minus 5 hours would be wrong for half the year because of daylight saving.- `pd....