AnalystPath

Total Stored Capacity Per Cold Room

PandasEasyJunior level~10 min

Problem

You are given two DataFrames:
- `roomstacks` with `room_label`, `produce_id`, `crate_qty` (how many crates of that produce sit in that room)
- `produce` with `produce_id`, `produce_label`, `dim_x_mm`, `dim_y_mm`, `dim_z_mm` (the crate dimensions in millimetres)

The volume of one crate is `dim_x_mm * dim_y_mm * dim_z_mm`. For each cold room, sum the total stored volume across all of its stacks (`crate_qty` times the crate volume, summed over every produce type in the room).

Return columns `cold_room` and `total_capacity`. Produce types that are not stacked in any room do not contribute.

Input data

Example rows — the live problem includes the full dataset.

roomstacks
room_labelproduce_idcrate_qty
Chiller-North11
Chiller-North210
Chiller-North35
Chiller-East12
Chiller-East22
produce
produce_idproduce_labeldim_x_mmdim_y_mmdim_z_mm
1Crisp Apples55040
2Cherry Tomatoes555
3Leaf Spinach21010
4Frozen Peas41020

Expected output

Your answer should return 3 rows with the columns cold_room, total_capacity.

Starter code (Pandas (Python))

import pandas as pd

def total_stored_capacity_per_cold_room(roomstacks, produce) -> pd.DataFrame:
    # Your code here
    return roomstacks

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