Avsnitt 1. Kapitel 9
single
Challenge: Analyzing Sales Data with Spark SQL
Svep för att visa menyn
Uppgift
Svep för att börja koda
You are given a flights dataset as a list of rows. Load it into a DataFrame, register it as a temporary view, and answer the following using spark.sql(). Store results in the specified variables:
- Find the top 3 routes (unique
AirportFrom+AirportTopairs) by averageLength– store as a list of tuples[(origin, destination, avg_length), ...]intop_routes_by_length; - For each airline, find the flight with the longest
Lengthusing a window function withrow_number()– store as a DataFrame inlongest_flight_per_airlinewith columnsAirline,Flight,Length; - Count how many delayed flights (
Delay == 1) perDayOfWeek– store as a list of tuples[(day_of_week, count), ...]sorted byDayOfWeekascending indelays_by_dow.
Print all results.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 1. Kapitel 9
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal