LoslegenKostenlos loslegen

Dropping missing data

In this exercise, you'll remove some of the rows where certain columns have missing values. You're going to look at the length_of_time column, the state column, and the type column. You'll drop any row that contains a missing value in at least one of these three columns.

Diese Übung ist Teil des Kurses

Preprocessing for Machine Learning in Python

Kurs anzeigen

Anleitung zur Übung

  • Print out the number of missing values in the length_of_time, state, and type columns, in that order, using .isna() and .sum().
  • Drop rows that have missing values in at least one of these columns.
  • Print out the shape of the new ufo_no_missing dataset.

Interaktive Übung

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

# Count the missing values in the length_of_time, state, and type columns, in that order
print(ufo[[____, ____, ____]].____.____)

# Drop rows where length_of_time, state, or type are missing
ufo_no_missing = ____

# Print out the shape of the new dataset
print(____)
Code bearbeiten und ausführen