How to fix 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''?
from sklearn.preprocessing import Imputer
imputer=Imputer(missing_values="np.nan",strategy="mean",axis=0)
imputer=imputer.fit(x[:,1:3])
x[:,1:3]=imputer.transform(x[:,1:3])
Traceback (most recent call last):
File "", line 3, in imputer=imputer.fit(x[:,1:3])
File "C:\Users\Nibir\Anaconda3\lib\site-packages\sklearn\preprocessing\imputation.py", line 167, in fit self.axis)
File "C:\Users\Nibir\Anaconda3\lib\site-packages\sklearn\preprocessing\imputation.py", line 254, in _dense_fit mask = _get_mask(X, missing_values)
File "C:\Users\Nibir\Anaconda3\lib\site-packages\sklearn\preprocessing\imputation.py", line 30, in _get_mask 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''