Underused Warehouse Stock

Medium
Arithmetic
Filtering

Underused Warehouse Stock

The inventory table records stock and capacity by warehouse.

Return warehouse, product_id, utilization_pct for rows where stock is below 25% of capacity. Round utilization to 2 decimal places. Sort by warehouse, then product_id ascending.

Browser Engine: Evaluates PySpark DataFrame & SQL logic locally in Pyodide WebAssembly.

Input data

1 DataFrame

These DataFrames are passed to solve(spark, dfs). Access one with dfs['name'].

df.inventory8 rows
warehouse (string)product_id (string)stock (int)capacity (int)
WH1P120100
WH1P230100
WH2P31040
WH2P4550
WH3P5020
WH3P64950
WH4P712100
WH4P825100

Return these columns

warehouse(string)
product_id(string)
utilization_pct(double)

Column names and order must match. Sort order is specified in the question.

Browser engine
Loading Python editor…
Click Run to try the sample cases, or Submit to check the hidden cases. First run caches the browser Python engine (~8–15s once); all code stays on your device.