Session Ready
Exercise

Generating & plotting delayed flights

Now that you have a function to compute flight delays, you'll apply it with a generator to analyze the percentage of delayed flights for each month of 2016.

You'll create a generator expression to loop over the provided list filenames and return a sequence of DataFrames. For each DataFrame, you'll then apply the function pct_delayed() (provided for you) within a list comprehension. Finally, you'll plot the results (matplotlib and pandas have been imported for you).

Warning: This exercise requires several seconds to execute.

Instructions
100 XP
  • Construct a generator called dataframes that applies pd.read_csv() to all the elements of the list filenames.
  • Make a list comprehension called monthly_delayed in which the function pct_delayed() is applied to every element of dataframes.
  • Hit 'Submit Answer' to generate the plot.