Reputation:
I have df with columns roll
, name
and present
. I'm trying to remove data where name == marcus
and present == False
.
roll name present
0 123 bruno False
1 123 bruno False
2 123 bruno True
3 78 marcus False (Remove this row)
4 78 marcus True
5 78 marcus True
Output:
roll name present
0 123 bruno False
1 123 bruno False
2 123 bruno True
4 78 marcus True
5 78 marcus True
Is it possible to remove that row without splitting tht dataframe
Upvotes: 1
Views: 809
Reputation: 16
Please try this.
df = df[!((df['name'] == 'marcus') && (df['present'] == False))]
Upvotes: 0
Reputation: 1094
Just do a selection:
df = df[(df['name'] != 'marcus') & (df['present'] != False)]
Remember to check for where name NOT equals marcus and present NOT equals False, because that is what you want to keep!
Upvotes: 0