I have multiple data frames (25 dataframes), I am looking for recurrently occuuring row values from three columns of all dataframes. The following are my example of my daframes
df1
chr start end name
1 12334 12334 AAA
1 2342 2342 SAP
2 3456 3456 SOS
3 4537 4537 ABR
df2
chr start end name
1 12334 12334 DSF
1 3421 3421 KSF
2 7689 7689 LUF
df3
chr start end name
1 12334 12334 DSF
1 3421 3421 KSF
2 4537 4537 LUF
3 8976 8976 BAR
4 6789 6789 AIN
And finally what I am aiming is to look into fist three columns of these daframe and extract a new dataframe based on matching rows from these 3 column values along with names of datafrme as last column. So the final data frame should look like this,
chr start end name Sample
1 12334 12334 AAA df1
1 12334 12334 AAA df2
1 12334 12334 AAA df3
I know the following line of python script will create the above output without Sample as a column.
s1 = pd.merge(df1, df2, how='left', on=['chr', 'start', 'end'])
df_final = pd.merge(s1, df3[['chr', 'start', 'end']], how='left', on=['chr', 'start','end'])
but I have more than 25 dataframe which I need to look for merge based on matching values. Any robust and better solution would be really appreciated