-4

I have a dictionary of 10 Dataframes, and every Dataframe has 2 columns which are same in all 10 Dataframes, I would like to inner join all these datframes on these 2 columns and get a single dataframe

Shivpe_R
  • 1,022
  • 2
  • 20
  • 31

1 Answers1

1

You can use DataFrame.merge with the functools.reduce function. Assuming your DataFrames are the values of your dictionary called df_dict:

from functools import reduce
df = reduce(lambda a, b: a.merge(b, on=['col1', 'col2']), df_dict.values())
jprebys
  • 2,469
  • 1
  • 11
  • 16