LoslegenKostenlos loslegen

Explode the bounds

You were able to transform the list-like column successfully, but you are not satisfied with the steps you had to take. You want to find an easier way to get the same reshaped DataFrame.

You remembered what you learned about exploding list-like columns, and you will apply a new strategy.

The same DataFrame obesity is available in your session. It contains the country, perc_obesity, and the column bounds with the minimum and maximum values you can find in different parts of the same country.

Diese Übung ist Teil des Kurses

Reshaping Data with pandas

Kurs anzeigen

Anleitung zur Übung

  • Transform the list-like column bounds in the DataFrame obesity to get its elements in different rows.
  • Modify the resulting DataFrame by resetting the index, dropping the old one.

Interaktive Übung

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

# Transform the list-like column named bounds  
obesity_explode = ____.____(____)

# Modify obesity_explode by resetting the index 
obesity_explode.____(drop=____, inplace=____)

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