Aan de slagGa gratis aan de slag

Mode and constant imputation

Filling in missing values with mean, median, constant and mode is highly suitable when you have to deal with a relatively small amount of missing values. In the previous exercise, you imputed using the mean and median methods. In this exercise, you'll fill in the most frequent values in the column and also perform another imputation by filling in a constant value.

As before, the diabetes DataFrame and the function SimpleImputer()have been loaded for you.

Deze oefening maakt deel uit van de cursus

Dealing with Missing Data in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Make a copy of diabetes
diabetes_mode = diabetes.copy(deep=True)

# Create mode imputer object
mode_imputer = SimpleImputer(___=___)

# Impute using most frequent value in the DataFrame mode_imputer
diabetes_mode.iloc[:, :] = mode_imputer.___(___)
Code bewerken en uitvoeren