Introduction
Grouping
12. Statistical functions in groups
Summary

Instruction

Great. Apart from size(), we can use all the other statistical functions that we got to know. For instance, if we want to find the average number of aces based on players’ height, we can use:

players_by_height['aces'].mean()

The result looks something like:

height
180 1689.000000
185 5060.000000
191 2366.500000
198 3658.666667
203 5837.000000
Name: aces, dtype: float64

Note that we can refer to specific columns using the brackets operator. In this case, we specified the aces column and calculated the mean for each height group.

Exercise

Calculate the total revenue from ticket sales in each country. To that end, use the sum() function on the box_office column.

Stuck? Here's a hint!

Start with

movies_by_country['box_office']