我正在尝试运行此代码:
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')]位于[列]“
请,让我知道怎么了? 谢谢