3

I want to drop rows with null values in both column a and b. I have managed to find those rows with:

df[(df['a'].isnull()) & (df['b'].isnull())]

How do I drop these rows?

Chia Yi
  • 532
  • 2
  • 5
  • 21

1 Answers1

0

Invert mask by ~:

df[~(df['a'].isnull() & df['b'].isnull())]

Or:

df[df[['a','b']].notnull().any(1)]
jezrael
  • 729,927
  • 78
  • 1,141
  • 1,090