Average Tip per Driver

Easy
Aggregation

Average Tip per Driver

The rides table records tips for each ride.

Return driver_id, avg_tip, the average tip per driver rounded to 2 decimal places. Sort by driver_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.rides8 rows
ride_id (int)driver_id (int)tip (double)
112
213
325
431.5
532.5
640
754.5
863.5

Return these columns

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