import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
#Import Data set
dataset= pd.read_csv('Data.csv')
X = dataset.iloc[:,:-1].values
Y = dataset.iloc[:,3].values
#Taking Care of The Missing Data
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values='nan',strategy='mean',axis=0)
imputer = imputer.fit(X[:,1:3])
X[:,1:3] = imputer.transform(X[:,1:3])
I was following this tutorial series and did exactly as he tutor did with me of course having this error as mentioned in the code. A potential solution would be of course very helpful. Thanks in advance.
Error : if value_to_mask == "NaN" or np.isnan(value_to_mask): TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
try :
imputer = Imputer(missing_values=np.nan,strategy='mean',axis=0)
or
imputer = Imputer(missing_values='NaN',strategy="mean",axis=0)
as mentioned in the documentation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.