CommencerCommencer gratuitement

A group analysis

You are almost done working for the day, but there is an extra analysis you want to do. You want to know if the mean and median percentage of obesity by country are different.

You analyze the DataFrame obesity. You realize that country is part of the column labels, so you need to reshape the DataFrame so country is part of the index.

You want to take a different approach. You will perform the desired calculations, combining the stacking process and .groupby() function.

The obesity DataFrame is available in your session. Make sure to examine it in the console!

Cet exercice fait partie du cours

Reshaping Data with pandas

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Stack country level, group by country and get the mean
obesity_mean = obesity.____(level=____).____(____).____

# Print obesity_mean
print(obesity_mean)
Modifier et exécuter le code