Day-of-Week by Hour Heatmap of Facebook Event RSVPs in Local Time
Last updated: November 29, 2026
Quick Overview
Given Facebook Event RSVPs with UTC timestamps and each user's time zone, build a 7 by 24 table of RSVP counts by local day of week and local hour in pandas. Every cell must exist, even if the count is zero.
Meta
November 29, 20260
0
0 solved
Given Facebook Event RSVPs with UTC timestamps and each user's time zone, build a 7 by 24 table of RSVP counts by local day of week and local hour in pandas. Every cell must exist, even if the count is zero.
A pandas warm-up for Events and notifications analysts, used to pick reminder send times. The interviewer checks per-row time zone conversion, pivoting, and reindexing to a full grid.
What the Interviewer Expects
- Convert each timestamp to the user's own time zone
- Extract day of week and hour from local time
- Pivot with counts
- Reindex to a complete 7 by 24 grid with zeros
- Label days clearly
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 vectorize the time zone conversion for millions of rows?
- Should the heatmap be normalized by active users per cell?
- What happens to the hour that repeats on a DST fallback day?
- How would you compare two countries' heatmaps?
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
rsvps has user_id, event_id, ts_utc (timezone-aware UTC) and tz (IANA name per user). Output rows Mon to Sun, columns hours 0 to 23. Counts, not rates....
Approach
Convert each row to its own zone, then take dayofweek (Monday = 0) and hour. pivot_table with aggfunc='size' counts, and reindex with fill_value=0 guarantees all 168 cells. For speed with ...