0

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?

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

1 Comment

So that's what the tilde does!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.