Lets say we have two dataframes df and df1 with different column names like sku as primary key and sno as its foreign key:
Example1(df)
sku loc flag
122 61 True
123 61 True
113 62 True
122 62 True
123 62 False
122 63 False
301 63 True
Example2(df1)
sno dept
113 a
122 b
123 b
301 c
I want to do a join or merge which looks like this:
Example3
sku loc flag dept
122 61 True b
123 61 True b
113 62 True a
122 62 True b
123 62 False b
122 63 False b
301 63 True c
Unfortunately df.merge(df1, on='sku', how='left')
and df['dept']=df.sku.map(df1.dept)
doesn't work.
Example modified from : vlookup in Pandas using join