Chapter 13. Grouping for Aggregation, Filtration, and Transformation
One of the most fundamental tasks during a data analysis involves splitting data into independent groups before performing a calculation on each group. This methodology has been around for quite some time but has more recently been referred to as split-apply-combine. This chapter covers the powerful groupby
method, which allows you to group your data in any way imaginable and apply any type of function independently to each group before returning a single dataset.
Note
Hadley Wickham coined the term split-apply-combine to describe the common data analysis pattern of breaking up data into independent manageable chunks, independently applying functions to these chunks, and then combining the results back together. More details can be found in his paper (http://bit.ly/2isFuL9).
Before we get started with the recipes, we will need to know just a little terminology. All basic groupby operations have grouping columns, and each unique...