KeyError:“ [Index(['OtherPerCap'],dtype ='object')]都不在[列]中”

时间:2020-04-20 17:50:11

标签: python imputation

我正在尝试运行此代码:

from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values = 'NaN', strategy = 'mean', axis = 0)
imputer = imputer.fit(data[['OtherPerCap']])
data[['OtherPerCap']] = imputer.transform(data[['OtherPerCap']])

我有这个错误:

/usr/local/lib/python3.6/dist-packages/pandas/core/indexing.py在 _validate_read_indexer(自身,键,索引器,轴,raise_missing) -> 1640提高KeyError(f“ [{{key}]都不在[{axis_name}]”“))KeyError:” [Index(['OtherPerCap'], dtype ='object')]位于[列]“

请,让我知道怎么了? 谢谢

0 个答案:

没有答案