The file datasets/orc/orders.orc holds one row per order in the ORC format.
Which payment method brings in the most money?
paths['orders'].order_status == 'Completed'.payment_method and collect the number of orders and the total
total_amount (rounded to two decimals).revenue descending, then by payment_method ascending.payment_method, order_count, revenue.File questions receive the path as a third argument:
from pyspark.sql import functions as F
def solve(spark, dfs, paths):
orders = spark.read.orc(paths['orders'])
# TODO: filter, aggregate and sort
return orders
The same data is also preloaded as dfs['orders'] 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'].
orders]Column names and order must match. Sort order is specified in the question.