1. Learn
  2. /
  3. Courses
  4. /
  5. Reshaping Data with pandas

Exercise

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!

Instructions 1/2

undefined XP
  • 1

    Stack the country level of obesity, group it by country, and take the mean of all the columns.

  • 2

    Stack the country level of obesity, group by country, and take the median of all the columns.