March 2020
Beginner to intermediate
352 pages
8h 40m
English
To form groups based on multiple categories, we can simply specify the column names in the groupby() function. Grouping will be done simultaneously with the first category, the second category, and so on.
Let's groupby using two categories, body-style and drive wheels, as follows:
double_grouping = df.groupby(["body-style","drive-wheels"])double_grouping.first()
The output of the preceding code is as follows:

Not only can we group the dataset with specific criteria, but we can also perform arithmetic operations directly on the whole group at the same time and print the output as a series or dataframe. There ...
Read now
Unlock full access