Supplier Product Count

Medium
Aggregation

Supplier Product Count

The products table records each product's supplier.

Return supplier, product_count for each supplier. Sort by supplier 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.products8 rows
product_id (string)supplier (string)
P1Acme
P2Acme
P3Beta
P4Gamma
P5Beta
P6Acme
P7Delta
P8Gamma

Return these columns

supplier(string)
product_count(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.