The file datasets/json/web_logs.json holds one object per web event. The events
with event_type == 'click_product' are product clicks - which products get the
most attention?
paths['web_logs'].event_type == 'click_product' and a product_id that is
not null (some clicks have no product).product_id.click_count descending, then by product_id ascending.product_id, click_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: filter, aggregate and sort
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.