The file datasets/tsv/users.tsv holds one row per customer. It is a tab
separated file, so the columns are split by a tab character. Where do the
customers live?
paths['users'].
A TSV is a CSV with sep='\t'.country and count them.user_count descending, then by country ascending.country, user_count.File questions receive the path as a third argument:
from pyspark.sql import functions as F
def solve(spark, dfs, paths):
users = spark.read.csv(paths['users'], header=True, inferSchema=True, sep='\t')
# TODO: group by country, count the users and sort the result
return users
The same data is also preloaded as dfs['users'] 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'].
users]Column names and order must match. Sort order is specified in the question.