I am unable to drop dataframe rows due to key error. I am trying:
df.drop(df['Year_Map'] == 2021], axis=0, inplace=True)
Error: raise KeyError(f"{labels[mask]} not found in axis"
What is the proper way to drop rows with a filter?
CodePudding user response:
df.drop(df[df.Year_Map == '2021'].index, inplace=True)