Merge Based On Multiple Columns Of All Excel Files From A Directory In Python
Say I have a dataframe df, and a directory ./ which has the following excel files inside: path = './' for root, dirs, files in os.walk(path): for file in files: if file
Solution 1:
The following code may works:
from functools import reduce
dfs = [df0, df1, df2, dfN]
df_final = reduce(lambda left, right: pd.merge(left, right, on=['date', 'city']), dfs)
Post a Comment for "Merge Based On Multiple Columns Of All Excel Files From A Directory In Python"