Session Ready
Exercise

Method chaining and filtering

We've seen that pandas supports method chaining. This technique can be very powerful when cleaning and filtering data.

In this exercise, a DataFrame containing flight departure data for a single airline and a single airport for the month of July 2015 has been pre-loaded. Your job is to use .str() filtering and method chaining to generate summary statistics on flight delays each day to Dallas.

Instructions
100 XP
  • Use .str.strip() to strip extra whitespace from df.columns. Assign the result back to df.columns.
  • In the 'Destination Airport' column, extract all entries where Dallas ('DAL') is the destination airport. Use .str.contains('DAL') for this and store the result in dallas.
  • Resample dallas such that you get the total number of departures each day. Store the result in daily_departures.
  • Generate summary statistics for daily Dallas departures using .describe(). Store the result in stats.