I'm trying to perform vlookup across multiple excel sheets and export the file but I kinda got stuck. Any help is highly appreciated.
Code below:
import pandas as pd
df1 = pd.read_excel('data.xls', sheet_name=None, header = 1)
df2 = pd.read_excel('key.xlsx', sheet_name = 'keys')
writer = pd.ExcelWriter('matched.xlsx')
for sheetname, df in df1.items():
df1.merge(df2,on='year', how = 'left')
df.to_excel(writer, sheetname, index=False)
writer.save()
Comments
Post a Comment