Break Down Delivery Time into Stages from an Order Event Log
Last updated: November 29, 2026
Quick Overview
Given a long-format order event log (created, confirmed, Dasher at store, picked up, delivered) with occasional duplicate and missing events, use pandas to compute each order's stage durations and the median stage times per market.
DoorDash
November 29, 20260
0
0 solved
Given a long-format order event log (created, confirmed, Dasher at store, picked up, delivered) with occasional duplicate and missing events, use pandas to compute each order's stage durations and the median stage times per market.
When DoorDash delivery times rise, the first question is which leg grew: merchant confirmation, Dasher travel to the store, waiting for food, or the drive. Take-home and Python rounds use this to test long-to-wide reshaping, duplicate handling and data quality judgment in pandas.
What the Interviewer Expects
- Pivot long events to one row per order with one column per stage
- Take the first timestamp per stage to absorb duplicate retried events
- Compute durations in minutes and treat negative durations as data errors
- Exclude incomplete orders (cancelled, missing delivered) from delivery-time medians
- Use medians, not means, for skewed duration data
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 report the share of orders with each kind of data quality problem?
- Wait at store grew 2 minutes in one market. How would you find which merchants drove it?
- How would you handle stacked orders where the Dasher picks up two orders at once?
- How would you do the same reshape in SQL?
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
events(order_id, event_type, ts) holds one row per event; retries can duplicate an event and cancelled orders never reach delivered. orders(order_id, market) gives the market. Stages: confirm (c...
Approach
Filter to known stage events, then pivot_table(index='order_id', columns='event_type', values='ts', aggfunc='min'); min dedupes and the result has one row per order. reindex guarantees every sta...