Total Stored Capacity Per Cold Room
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.
| room_label | produce_id | crate_qty |
|---|---|---|
| Chiller-North | 1 | 1 |
| Chiller-North | 2 | 10 |
| Chiller-North | 3 | 5 |
| Chiller-East | 1 | 2 |
| Chiller-East | 2 | 2 |
| produce_id | produce_label | dim_x_mm | dim_y_mm | dim_z_mm |
|---|---|---|---|---|
| 1 | Crisp Apples | 5 | 50 | 40 |
| 2 | Cherry Tomatoes | 5 | 5 | 5 |
| 3 | Leaf Spinach | 2 | 10 | 10 |
| 4 | Frozen Peas | 4 | 10 | 20 |
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 roomstacksSolve 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