当我们的数据集位于python中的数据框架值中时,如何用均值填充缺失值

时间:2019-08-02 05:00:03

标签: python pandas numpy encoding numpy-ndarray

当我尝试用我的缺失值填充我的缺失值时,我的数据集已分发到X和y均为数据帧格式:

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''

dataSet = pd.read_csv('Data.csv')
X = dataSet.iloc[:, :-1]
y = dataSet.iloc[:, 3]
y = pd.DataFrame(y)

#Taking care of missing Data
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values="Nan", strategy="mean", axis=0)
imputer = imputer.fit(X.iloc[:, 1:3])
X.iloc[:,1:3] = imputer.transform(X.iloc[:,1:3])

我希望我的数据必须填充平均法力值

0 个答案:

没有答案