How it works...

To group by multiple columns as in step 1, we pass a list of the string names to the groupby method. Each unique combination of AIRLINE and WEEKDAY forms an independent group. Within each of these groups, the sum of the cancelled flights is found and then returned as a Series.

Step 2, again groups by both AIRLINE and WEEKDAY, but this time aggregates two columns. It applies each of the two aggregation functions, sum and mean, to each column resulting in four returned columns per group.

Step 3 goes even further, and uses a dictionary to map specific aggregating columns to different aggregating functions. Notice that the size aggregating function returns the total number of rows per group. This is different than the count aggregating function, which returns the number of non-missing values per group.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset