AnalystPath

Distinct Vehicle Types Parked per Day

PandasEasyJunior level~10 min

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.

entries
entry_dayvehicle
2021-11-04Coupe
2021-11-04Sedan
2021-11-04Van
2021-11-05Bike
2021-11-05Truck

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 entries

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