Skip to content
Advertisement

In Pandas, how to delete rows from a Data Frame based on another Data Frame?

I have 2 Data Frames, one named USERS and another named EXCLUDE. Both of them have a field named “email”.

Basically, I want to remove every row in USERS that has an email contained in EXCLUDE.

How can I do it?

Advertisement

Answer

You can use boolean indexing and condition with isin, inverting boolean Series is by ~:

JavaScript
JavaScript

Another solution with merge:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement