Product First Sale Day

Medium
Aggregation

Product First Sale Day

The sales table records product sales by day.

Return product_id, first_sale_day for each product. 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.sales8 rows
sale_id (int)product_id (string)sale_day (int)
1P15
2P12
3P21
4P37
5P33
6P44
7P56
8P52

Return these columns

product_id(string)
first_sale_day(int)

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.