Trying to import Imputer from sklearn,
import pandas as pd
dataset = pd.read_csv(\'Data.csv\')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 3].values
Try this:
from sklearn.impute import SimpleImputer
imr = SimpleImputer(missing_values=np.nan, strategy='mean')
imr = imr.fit(df.values)
imputed_data = imr.transform(df.values)
print (imputed_data)
Note: New changes are in boldface for your quick reference.
The class is deprecated, use
from sklearn.impute import SimpleImputer
imputer = SimpleImputer(missing_values=np.nan, strategy='mean')
After the version scikit-learn SimpleImputer/Imputer has been changed its location from sklearn.preprocessing to package sklearn.impute.
So, kindly use the below line of code to import.
from sklearn.impute import SimpleImputer
Thank you!