Skip to content
Advertisement

Comparing two data frames with different columns and getting the differences

I have a similar question as here Comparing two data frames and getting the differences But columns in df1 is a subset of columns in df2.

JavaScript

I would like to get the difference the two df by comparing those columns in common only. So the result I expect to get is

JavaScript

Is there a way to do so? Any help is appreciated.

Advertisement

Answer

First you get the column names of df1

JavaScript

Now you create a new df2 dataframe with only df1 columns

JavaScript

And now you can apply the solution from this other question.

JavaScript

Hope it helps!

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