Reputation: 1993
I need to drop some rows from a pandas dataframe aa
based on a query as follows:
aa.loc[(aa['_merge'] == 'right_only') & (aa['Context Interpretation'] == 'Topsoil')]
How do I drop this selection from the datafram aa
?
Upvotes: 0
Views: 54
Reputation: 323226
You can do add '~'
out = aa.loc[~((aa['_merge'] == 'right_only') & (aa['Context Interpretation'] == 'Topsoil'))]
Or
idx = aa.index[(aa['_merge'] == 'right_only') & (aa['Context Interpretation'] == 'Topsoil')]
out = aa.drop(idx)
Upvotes: 1