AnalystPath

Total Parking Minutes per Vehicle

PandasEasyJunior level~10 min

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.

parking_event
vehicle_idpark_dateenter_minexit_min
12026-02-103090
12026-02-10100130
22026-02-10045
12026-02-116080

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_event

Solve 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

Related Pandas questions