Distinct Vehicle Types Parked per Day
Problem
You are given a DataFrame `entries` with columns `entry_day` and `vehicle`. It may contain duplicate rows. Each row records one vehicle type that entered a parking garage on a given day.
For each day, report how many different vehicle types entered and a comma-separated list of those distinct types, sorted alphabetically. Return the result ordered by `entry_day`. Name the columns `entry_day`, `kinds`, and `vehicles`.
Input data
Example rows — the live problem includes the full dataset.
| entry_day | vehicle |
|---|---|
| 2021-11-04 | Coupe |
| 2021-11-04 | Sedan |
| 2021-11-04 | Van |
| 2021-11-05 | Bike |
| 2021-11-05 | Truck |
Expected output
Your answer should return 3 rows with the columns entry_day, kinds, vehicles.
Starter code (Pandas (Python))
import pandas as pd
def distinct_vehicle_types_parked_per_day(entries) -> pd.DataFrame:
# Your code here
return entriesSolve 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