Repeat Buyers

Easy
Aggregation

Repeat Buyers

The orders table records individual purchases.

Return customer_id, order_count for customers who placed at least 2 orders. Sort by order_count descending, then customer_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.orders7 rows
order_id (int)customer_id (int)amount (double)
110120
210230
310115
410350
510210
610125
71045

Return these columns

customer_id(int)
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.