I have an array wrong_indexes_train
which contains a list of indexes that I would like to remove from a dataframe:
[0, 63, 151, 469, 1008]
To remove these indexes, I am trying this:
df_train.drop(wrong_indexes_train)
However, the code fails with the error:
ValueError: labels ['OverallQual' 'GrLivArea' 'GarageCars' 'TotalBsmtSF' 'FullBath'
'YearBuilt'] not contained in axis
Here, ['OverallQual' 'GrLivArea' 'GarageCars' 'TotalBsmtSF' 'FullBath' 'YearBuilt']
are the names of my dataframe's columns.
How could I just make the dataframe drop the entire rows of the indices that I specified?
Change it to
df_train.drop(wrong_indexes_train,axis=1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With