Daily Distinct Buyers and Couriers
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_date | hub_code | buyer_id | courier_id |
|---|---|---|---|
| 2026-01-01 | north | 7 | 3 |
| 2026-01-01 | north | 7 | 4 |
| 2026-01-01 | north | 8 | 3 |
| 2026-01-01 | south | 9 | 5 |
| 2026-01-02 | north | 7 | 3 |
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_logSolve 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