Reputation: 189
I have the following DF:
I want to remove all rows whereby TO and GP columns are negative and '0', and remove all rows whereby TTS and BMI columns are positive and '0'.
I have tried creating code like the following for each column however this is also deleting rows that are null which I do not want:
df [df ['GP'] >= 0]
What's the most efficient way to do this?
Upvotes: 0
Views: 37
Reputation: 10624
Try with df.drop:
df.drop(df[(df.TO <= 0) | (df.GP <=0) | (df.TS >= 0) | (df.BMI >=0)].index, inplace=True)
Upvotes: 1