I have got 7 dataframes with same column names in python, but row indices are largely different and only few of the row indices match.
df1
col1 col2 col3
a 123 456 786
b 121 454 787
c 111 444 777
df2
col1 col2 col3
d 13 46 86
e 11 44 87
c 11 44 77
df3
col1 col2 col3
d 1231 4567 1786
g 1214 4546 1787
h 1115 4445 1777
c 12 12 10
Answer should be:
newdf
newcol col1 col2 col3 dfcol
c 111 444 777 1
c 11 44 77 2
c 12 12 10 3
d 13 46 86 2
d 1231 4567 1786 3
It is similar to this How to get the common index of two pandas dataframes? but not exactly.