Skip to content
Advertisement

How to drop rows in one DataFrame based on one similar column in another Dataframe that has a different number of rows

I have two DataFrames that are completely dissimilar except for certain values in one particular column:

JavaScript
JavaScript

How would I go about finding the matching values in the Email column of df and the Contact column of df2, and then dropping the whole row in df based on that match?

Output I’m looking for (index numbering doesn’t matter):

JavaScript

I’ve been able to identify matches using a few different methods like:

Changing the column names to be identical

JavaScript

But df3 still shows all the rows from df.

I’ve also tried:

JavaScript

And again, identifies the matches but df still contains all original rows.

So the main thing I’m having difficulty with is updating df with the matches dropped or creating a new DataFrame that contains only the rows with dissimilar values when comparing the Email column from df and the Contact column in df2. Appreciate any suggestions.

Advertisement

Answer

As mentioned in the comments(@Arkadiusz), it is enough to filter your data using the following

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