LoslegenKostenlos loslegen

Less fast food, please!

Monday again! You will start working on a new project - analyzing the evolution of obesity through the years. You have a dataset called obesity with the percentage of obesity in different countries and years. The data is also disaggregated by biological sex.

Your main goals are to get the mean percentage of obesity by year and sex, and by country and sex. Also, you want to get the difference between years.

You notice that the dataset has multiple indices, so you know you will have to unstack levels to accomplish your goal.

The obesity DataFrame is available in your session.

Diese Übung ist Teil des Kurses

Reshaping Data with pandas

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Unstack the first level and calculate the mean of the columns
obesity_general = obesity.____(____=____).____(____)

# Print obesity_general
print(obesity_general)
Code bearbeiten und ausführen