Abschnitt 1. Kapitel 9
single
Challenge: Analyzing Sales Data with Spark SQL
Swipe um das Menü anzuzeigen
Aufgabe
Wischen, um mit dem Codieren zu beginnen
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ösung
War alles klar?
Danke für Ihr Feedback!
Abschnitt 1. Kapitel 9
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen