March 2020
Beginner to intermediate
352 pages
8h 40m
English
The most important operations groupBy implements are aggregate, filter, transform, and apply. An efficient way of implementing aggregation functions in the dataset is by doing so after grouping the required columns. The aggregated function will return a single aggregated value for each group. Once these groups have been created, we can apply several aggregation operations to that grouped data.
Let's group the DataFrame, df, by body-style and drive-wheels and extract stats from each group by passing a dictionary of aggregation functions:
# Group the data frame df by body-style and drive-wheels and extract stats from each groupdf.groupby( ["body-style","drive-wheels"]).agg( { 'height':min, # minimum height of car in each ...Read now
Unlock full access