Count Orders by Status

Easy
Aggregation

Count Orders by Status

The orders table contains one row per order.

Return status, order_count with the number of orders in each status. Sort by status 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.orders7 rows
order_id (int)status (string)
1delivered
2pending
3delivered
4cancelled
5delivered
6pending
7returned

Return these columns

status(string)
order_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.