Heaviest Parcel Shipped Each Day
Problem
You are given a DataFrame `shipments` with columns `parcel_id`, `ship_ts` (a datetime string), and `weight_kg`. Each row is one parcel that left a logistics depot.
Flag the heaviest parcel sent out on each **calendar day**. If two or more parcels on the same day tie for the highest weight, flag all of them.
Return a single column `parcel_id`, ordered by `parcel_id` ascending.
Input data
Example rows — the live problem includes the full dataset.
shipments
| parcel_id | ship_ts | weight_kg |
|---|---|---|
| 1 | 2023-09-01 08:15:00 | 12 |
| 2 | 2023-09-01 16:40:00 | 30 |
| 3 | 2023-09-01 11:00:00 | 30 |
| 4 | 2023-09-02 09:00:00 | 7 |
| 5 | 2023-09-02 18:30:00 | 22 |
Expected output
Your answer should return 4 rows with the columns parcel_id.
Starter code (Pandas (Python))
import pandas as pd
def heaviest_parcel_each_day(shipments) -> pd.DataFrame:
# Your code here
return shipmentsSolve 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