Orders Per User

Easy
GroupBy
Aggregations
Pinterest
Salesforce

Orders Per User

Count rows per user_id in orders and return as order_count. Sort by user_id ascending.

Sample input

user_idorder_id
31
42
13
44
25
46
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.orders10 rows
user_id (int)order_id (int)
31
42
13
44
25
46
37
18
29
310

Return these columns

user_id(int)
order_count(long)

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.