Drop rows by index from dataframe
Change it to
df_train.drop(wrong_indexes_train,axis=1)
Not 100% certain what you want without a minimum-(not)working-example, but you should specify an axis
parameter. df.drop
returns the modified DataFrame
. If you want to operate inplace, specify inplace=True
.
See this for symbolic row names (index):
df = pd.DataFrame({"ones":[1,3,5],
"tens":[20, 40, 60]},
index=['barb', 'mark', 'ethan'])
df.drop(['barb', 'mark'], axis='index')
And this for numeric (default) indices:
df = pd.DataFrame({"ones":[1,3,5],
"tens":[20, 40, 60]})
df.drop([0,2], axis='index')