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!
This exercise is part of the course
Reshaping Data with pandas
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Stack country level, group by country and get the mean
obesity_mean = obesity.____(level=____).____(____).____
# Print obesity_mean
print(obesity_mean)