0

I want to drop all rows if the value in a column matches an item in a list. I tried:

bets.drop(bets[bets["id_"] in bet_ids].index, inplace=True)

However, I got the error:

The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

I tried adding any():

bets.drop(bets[any(bets["id_"] in bet_ids)].index, inplace=True)

But get the same error.

Where am I going wrong?

Jossy
  • 589
  • 2
  • 12
  • 36

1 Answers1

1

You should do with isin

bets.drop(bets.index[bets["id_"].isin(bet_ids)], inplace=True)
BENY
  • 317,841
  • 20
  • 164
  • 234