Categories
Python Answers

How to use Python Pandas get rows which are NOT in other dataframe?

Spread the love

To use Python Pandas get rows which are NOT in other dataframe, we can use isin with negation.

For instance, we write

df1[~df1.index.isin(df2.index)]

to call isin with the index of the df1 data frame that are in fd2.inex list.

And then we negate that to get the rows in df1 that aren’t in the df2 data frame.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *