I have two data frames df1 and df2 with a common column ID. Both the data frames have different number of rows and columns. I want to compare these two dataframe ID’s. I want to create another column y in df1 and for all the common id’s present in df1 and df2 the value of y should be 0 else 1. For example df1 is
Id col1 col2
1 Abc def
2 Geh ghk
3 Abd fg
1 Dfg abc
And df2 is
Id col3 col4
1 Dgh gjs
2 Gsj aie
The final dataframe should be
Id col1 col2 y
1 Abc def 0
2 Geh ghk 0
3 Abd fg 1
1 Dfg abc 0