LoslegenKostenlos loslegen

Fixing string errors in a DataFrame

You are given the heroes dataset containing the information on different comic book heroes. However, you'll need to make some refinements in order to use this dataset further.

Comparing Eye color, Hair color, and Skin color columns, you can see that strings in the Hair color columns are capitalized, whereas in other two the strings are lowercased.

Moreover, some rows in the Gender column contain a spelling error (Fmale instead of Female).

Your task is to make the strings in the Hair color column lowercased and to fix the spelling error in the Gender column.

Diese Übung ist Teil des Kurses

Practicing Coding Interview Questions in Python

Kurs anzeigen

Interaktive Übung

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

# Make all the values in the 'Hair color' column lowercased
heroes[____] = heroes[____].____.____
  
# Check the values in the 'Hair color' column
print(heroes['Hair color'].value_counts())
Code bearbeiten und ausführen