The file datasets/parquet/employees.parquet holds one row per employee in the
columnar Parquet format. How big is the payroll of every department?
paths['employees'].department_id and collect the number of employees and the
total salary (rounded to two decimals).payroll descending, then by department_id ascending.department_id, headcount, payroll.File questions receive the path as a third argument:
from pyspark.sql import functions as F
def solve(spark, dfs, paths):
employees = spark.read.parquet(paths['employees'])
# TODO: aggregate and sort
return employees
The same data is also preloaded as dfs['employees'] if you prefer to skip the file read.
This question runs in your browser - no sign-in needed. Press Run for the sample data and Submit for the hidden data.
These files are loaded into this browser when you run. Their paths are handed to your code as the third argument: solve(spark, dfs, paths). Read one with spark.read.csv(paths['users'], header=True), or skip the read and use dfs['users'].
employees]Column names and order must match. Sort order is specified in the question.