
Slow deliveries by cuisine
mediumSlow deliveries by cuisine
DoorDash Pandas Interview Question
DoorDash promises most orders within 30 minutes. The restaurant success team wants to know which cuisines miss that most often.
Use the deliveries and restaurants DataFrames and count delivered orders only. Return each cuisine with the number of delivered orders as delivered_orders and the percentage that took more than 30 minutes from order to delivery as slow_pct, rounded to 1 decimal place. Sort the rows by slow_pct, highest first. Assign the answer to result.
Asked of
- Data Analyst
- Product Analyst
- Business Analyst
- Analytics Engineer
- Data Scientist
deliveriesDataFrame12 rows
| Column Name | Type |
|---|---|
| delivery_id | int64 |
| restaurant_id | int64 |
| dasher_id | int64 |
| ordered_at | str |
| delivered_at | str |
| order_value | float64 |
| status | str |
restaurantsDataFrame6 rows
| Column Name | Type |
|---|---|
| restaurant_id | int64 |
| restaurant_name | str |
| cuisine | str |
| city | str |
deliveriesExample Input
| delivery_id | restaurant_id | dasher_id | ordered_at | delivered_at | order_value | status |
|---|---|---|---|---|---|---|
| 7001 | 1 | 51 | 2024-04-12 11:58:00 | 2024-04-12 12:26:00 | 32.4 | delivered |
| 7002 | 2 | 52 | 2024-04-12 12:05:00 | 2024-04-12 12:41:00 | 27.8 | delivered |
| 7003 | 3 | 53 | 2024-04-12 12:20:00 | NULL | 18.5 | canceled |
| 7004 | 4 | 54 | 2024-04-12 18:02:00 | 2024-04-12 18:48:00 | 45.6 | delivered |
| 7005 | 5 | 55 | 2024-04-12 18:15:00 | 2024-04-12 18:37:00 | 22.1 | delivered |
| 7006 | 1 | 52 | 2024-04-12 18:30:00 | 2024-04-12 19:04:00 | 41.25 | delivered |
| 7007 | 6 | 56 | 2024-04-12 19:10:00 | 2024-04-12 19:52:00 | 36.9 | delivered |
restaurantsExample Input
| restaurant_id | restaurant_name | cuisine | city |
|---|---|---|---|
| 1 | Taco Loco | Mexican | San Francisco |
| 2 | Pho Real | Vietnamese | San Francisco |
| 3 | Burger Barn | American | San Francisco |
| 4 | Curry House | Indian | Denver |
| 5 | Nacho Mama | Mexican | Denver |
| 6 | Big Bite Burgers | American | Denver |
Example Output
| cuisine | delivered_orders | slow_pct |
|---|---|---|
| American | 1 | 100 |
| Indian | 1 | 100 |
| Vietnamese | 1 | 100 |
| Mexican | 3 | 33.3 |
Explanation
Taco Loco and Nacho Mama both serve Mexican food. Their three deliveries took 28, 22 and 34 minutes, so one of the three was slow, which is 33.3%. Order 7003 was canceled, so it is not counted.
The example above is a small slice of the data. Your code runs against the full DataFrames.
Company
DoorDash
Difficulty
medium
Topic
dates
Language
Pandas
Your code
Loading Python in the background. You can start writing.