The file datasets/json/web_logs.json is a newline-delimited JSON file with one
object per web event. Count the events per event_type.
paths['web_logs'].event_type and count them.event_type ascending.event_type, event_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['web_logs'])
# TODO: group by event_type, count the events and sort the result
return logs
The same data is also preloaded as dfs['web_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'].
web_logs]Column names and order must match. Sort order is specified in the question.