我有一个数组 wrong_indexes_train
其中包含我想从数据框中删除的索引列表:
[0, 63, 151, 469, 1008]
要删除这些索引,我正在尝试这样做:
df_train.drop(wrong_indexes_train)
但是,代码失败并出现错误:
ValueError: labels ['OverallQual' 'GrLivArea' 'GarageCars' 'TotalBsmtSF' 'FullBath'
'YearBuilt'] not contained in axis
在这里, ['OverallQual' 'GrLivArea' 'GarageCars' 'TotalBsmtSF' 'FullBath' 'YearBuilt']
是我的数据框列的名称。
我怎样才能让数据框删除我指定的索引的整行?
原文由 bsky 发布,翻译遵循 CC BY-SA 4.0 许可协议
改成