question 425 pandas Transformations · medium
Departed flights per airline and airport
Write departures_grid(flights): from a flights DataFrame (airline_code, origin, cancelled as 0/1, and more), return a table with one row per airline and one column per origin airport, counting the flights that actually departed (cancelled == 0), with 0 where an airline had none from that airport. Airlines and airports with no departed flight at all don't appear.
Function
departures_grid(flights)Returnsa DataFrame: index = airline codes, columns = origin airports, values = counts