AnalystPath

Daily Distinct Buyers and Couriers

PandasEasyJunior level~10 min

Problem

You are given a DataFrame `parcel_log` with columns `ship_date`, `hub_code`, `buyer_id`, `courier_id`.

For each combination of `ship_date` and `hub_code`, return the number of distinct buyers and the number of distinct couriers. Output columns: `ship_date`, `hub_code`, `distinct_buyers`, `distinct_couriers`.

Input data

Example rows — the live problem includes the full dataset.

parcel_log
ship_datehub_codebuyer_idcourier_id
2026-01-01north73
2026-01-01north74
2026-01-01north83
2026-01-01south95
2026-01-02north73

Expected output

Your answer should return 3 rows with the columns ship_date, hub_code, distinct_buyers, distinct_couriers.

Starter code (Pandas (Python))

import pandas as pd

def daily_distinct_buyers_couriers(parcel_log) -> pd.DataFrame:
    # Your code here
    return parcel_log

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