The file datasets/json/product_reviews.json holds one object per review. Which
products are rated best - but only if enough people reviewed them?
paths['product_reviews'].product_id and collect the number of reviews and the average
rating (rounded to two decimals).avg_rating descending, then by product_id ascending.product_id, review_count, avg_rating.File questions receive the path as a third argument:
from pyspark.sql import functions as F
def solve(spark, dfs, paths):
reviews = spark.read.json(paths['product_reviews'])
# TODO: aggregate, filter and sort
return reviews
The same data is also preloaded as dfs['product_reviews'] 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'].
product_reviews]Column names and order must match. Sort order is specified in the question.