0

I am trying to filter my DataFrame based on the following expression:

df = df[not(df['var1'] == (1 or 2 or 3) and df['var2'].isnull())]

Essentially, I would like to keep the dataframe without the rows where var1 has a value of 1, 2 or 3 and there is no input for var2. However, I get the following return:

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

I don't know which one to use and when I use a couple of them they return an empty DataFrame. How can I solve this?

SDR3078
  • 45
  • 8

0 Answers0