Enhancing the groupby Function

Learn how to enhance the groupby function by using its parameters and named aggregations.

Named aggregations

In the previous lesson, we selected the product_group and price columns before applying the groupby and mean functions so that the output only shows the product groups and average prices. We do not have to select the columns beforehand if we use named aggregations. We can simply specify the name of the column and the type of aggregate function. Another advantage of using named aggregations is that we can assign a more descriptive name to the aggregated column. Let’s repeat the example in the previous lesson with a named aggregation.

Get hands-on with 1200+ tech skills courses.