Total Spend Per User

Easy
GroupBy
Aggregations
Twilio
Meta

Total Spend Per User

Given orders(user_id, amount), return the sum of amount per user_id as total_amount. Sort by user_id ascending.

Sample input

user_idamount
4189.04
567.44
313.07
567.08
5145.42
1166.43
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)amount (double)
4189.04
567.44
313.07
567.08
5145.42
1166.43
5166.69
586.28
275.96
4120.75

Return these columns

user_id(int)
total_amount(double)

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.