AnalystPath

Total Parcel Weight per Courier

PandasEasyJunior level~10 min

Problem

A delivery depot tracks every parcel its couriers carry.

`couriers` (`couriers.csv`): `courier_id`, `courier_name` — one courier per row.

`deliveries` (`deliveries.csv`): `delivery_id`, `courier_id`, `weight_kg` — each row is one delivered parcel and the weight the named courier carried.

Report, for every courier, the total weight they delivered as `total_weight`. A courier with no deliveries should report `0`. Order the result by `total_weight` descending; when two or more couriers tie, order those by `courier_name` ascending. Return the columns `courier_name` and `total_weight`.

Input data

Example rows — the live problem includes the full dataset.

couriers
courier_idcourier_name
1Mia
2Owen
3Ava
4Noah
7Leo
deliveries
delivery_idcourier_idweight_kg
11120
22317
33222
47100
513312

Expected output

Your answer should return 7 rows with the columns courier_name, total_weight.

Starter code (Pandas (Python))

import pandas as pd

def total_weight_per_courier(couriers: pd.DataFrame, deliveries: pd.DataFrame) -> pd.DataFrame:
    # Your code here
    return couriers

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