The file datasets/json/attendance_logs.json holds one object per attendance
record. How many different employees does every attendance status cover?
paths['attendance_logs'].status and count the distinct employee_id values.employee_count descending, then by status ascending.status, employee_count.File questions receive the path as a third argument:
from pyspark.sql import functions as F
def solve(spark, dfs, paths):
logs = spark.read.json(paths['attendance_logs'])
# TODO: group by status, count the distinct employees and sort the result
return logs
The same data is also preloaded as dfs['attendance_logs'] 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'].
attendance_logs]Column names and order must match. Sort order is specified in the question.