Spatial Digger
Spatial Digger

Reputation: 1993

Drop rows from pandas dataframe

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

Answers (1)

BENY
BENY

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

Related Questions