I have a master data that I wish to do vlookups for additional columnns. Here's what I am aiming to achieve:
Master Data:
Ctry Product
CN BTL
VN HP
Ref table 1:
Ctry Country
AU Australia
CN China
VN Vietnam
Ref table 2:
ProductID Product
BTL Bottles
HP Handphone
PRN Printer
How do I achieve it to combine all into the Master Data as below?
Expected Output:
Ctry Product Country Product
CN BTL China Bottles
VN HP Vietnam Handphone
My below codes only references 1 table and I'm stuck, how do I go about adding the additional columns to the existing Master Data Sheet?:
import pandas as pd
# IMPORT DATA
df1 = pd.read_excel("Masterdata.xlsx")
df2 = pd.read_excel("Ref_table_1.xlsx")
Left_join = pd.merge(df1,df2, on = 'Ctry', how ='left')
Left_join.to_excel("Output.xlsx", index = False)