Pandas offers several options for grouping and summarizing data. We've already discussed groupby, aggregation, and transformation, but there are other options available, such as pivot_table and crosstab. First, let's understand pivot tables.
Pivot tables and cross-tabulations
Pivot tables
The pandas.pivot_table() function creates a spreadsheet-style pivot table as a dataframe. The levels in the pivot table will be stored in MultiIndex objects (hierarchical indexes) on the index and columns of the resulting dataframe.
The simplest pivot tables must have a dataframe and an index/list of the index. Let's take a look at how to do this:
- Let's make a pivot table of a new dataframe that consists of the body-style...