DoorDash Average Earnings per Weekday
Problem
**[Asked at DoorDash]**
For each weekday (Monday, Tuesday, ...), compute the average delivery earnings.
Return `weekday` and `avg_earnings` (rounded to 2 dp), ordered by avg_earnings
descending.
Input data
Example rows — the live problem includes the full dataset.
deliveries
| delivery_id | driver_id | delivery_time | earnings |
|---|---|---|---|
| 1 | 101 | 2023-01-02 09:00 | 15.0 |
| 2 | 101 | 2023-01-02 18:00 | 25.0 |
| 3 | 102 | 2023-01-03 09:00 | 12.0 |
| 4 | 102 | 2023-01-09 09:00 | 18.0 |
| 5 | 103 | 2023-01-09 19:00 | 30.0 |
Expected output
Your answer should return 2 rows with the columns weekday, avg_earnings.
Starter code (Pandas (Python))
import pandas as pd
def avg_earnings(deliveries: pd.DataFrame) -> pd.DataFrame:
# Your code here
return deliveriesSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock