0

I have two columns in the table, speed and power. I would like to exclude any 0 for power where speed is greater than 5.

So far I have

df[(df.sum(axis=1) != 0)] 

which will exclude all 0 values but how do I amend that to also exclude all speeds greater than 5, while also including below 5?

leaf
  • 25
  • 1
  • 1
  • 5

1 Answers1

0

You can try this -

drop_idx = df[df.power == 0) & (df.speed > 5)].index

df = df.drop(index=drop_idx)
 

Your df will contain all the required rows

Vaebhav
  • 4,672
  • 1
  • 13
  • 33