Imputation of Missing Values
In this section, we will be looking at two different methods that we can use to handle the missing values:
- Mean imputation
- Iterative imputation
Let's look at each of these methods in detail.
Mean Imputation
In mean imputation, the missing values are filled with the mean of each column where the missing values are located. We will be performing mean imputation on the DataFrames in the next exercise.
Exercise 4.03: Performing Mean Imputation on the DataFrames
In this exercise, you will perform mean imputation on the first DataFrame. This exercise is a continuation of Exercise 4.02, Performing Missing Value Analysis for the DataFrames. Follow these steps to complete this exercise:
- Import
Imputer
fromsklearn.preprocessing
to perform mean imputation to fill in the missing values:from sklearn.impute import SimpleImputer imputer = SimpleImputer(missing_values=np.nan, \ Â Â Â Â Â Â Â Â ...