Reputation: 2269
How do I drop all dataframe rows that don't match a pair of conditions.
I did this:
df = df[ ! ((df['FVID'] == 0) & (df['vstDelta'] == 0)) ]
but that was a syntax error. Hopefully it illustrates what I want to do, which is to drop all records containing these 2 conditions.
Upvotes: 3
Views: 5904
Reputation: 19957
You should use '~' instead of ! to get the negation of the condition.
df = df[~((df['FVID'] == 0) & (df['vstDelta'] == 0))]
Upvotes: 5