Inventory Value by Product

Easy
Arithmetic

Inventory Value by Product

The inventory table stores units on hand and unit cost.

Return product_id, inventory_value, where the value is units * unit_cost, rounded to 2 decimal places. Sort by 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.inventory5 rows
product_id (string)units (int)unit_cost (double)
P1105.5
P209.99
P3252.4
P4712.5
P53100

Return these columns

product_id(string)
inventory_value(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.