AnalystPath

Heaviest Parcel Shipped Each Day

PandasMediumMid level~10 min

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_idship_tsweight_kg
12023-09-01 08:15:0012
22023-09-01 16:40:0030
32023-09-01 11:00:0030
42023-09-02 09:00:007
52023-09-02 18:30:0022

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 shipments

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