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

Exercise

Only going up

After your last analysis, you are excited to keep working with the obesity dataset. You have added an extra column, the variation column, which indicates the range in which the percentage varies through regions in the same country. You are not sure if the mean is the best metric to summarize obesity levels.

So you decide to explore the median percentage and variation of obesity by year and biological sex. Also, you want to get the maximum percentage observed by country, year, and biological sex.

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

Instructions 1/2

undefined XP
  • 1

    Stack the obesity DataFrame, get the median value of the columns, and finally, unstack it again.

  • 2

    Stack obesity by the first level, get the sum of the columns, and finally, unstack the DataFrame by the second level.