Total Parking Minutes per Vehicle
Problem
A `parking_event` DataFrame logs garage stays. Each row has `vehicle_id`, `park_date`, `enter_min` (the minute the vehicle entered) and `exit_min` (the minute it left). A vehicle may park several times in one day.
For each `park_date` and `vehicle_id`, return the total number of minutes the vehicle spent parked that day. Output columns `day` (the `park_date`), `vehicle_id`, and `total_minutes`.
Input data
Example rows — the live problem includes the full dataset.
| vehicle_id | park_date | enter_min | exit_min |
|---|---|---|---|
| 1 | 2026-02-10 | 30 | 90 |
| 1 | 2026-02-10 | 100 | 130 |
| 2 | 2026-02-10 | 0 | 45 |
| 1 | 2026-02-11 | 60 | 80 |
Expected output
Your answer should return 3 rows with the columns day, vehicle_id, total_minutes.
Starter code (Pandas (Python))
import pandas as pd
def total_parking_minutes(parking_event: pd.DataFrame) -> pd.DataFrame:
# Your code here
return parking_eventSolve 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