I have to merge two DataFrame, with a Left Join - Illustration below.
Problem is that the matching key is spread across 3 columns. To further complicate the challenge, some rows (#4) will have the same matching key twice! I was advised to use Melt but it only work for a Right Join.
What is the best approach?
import pandas as pd
data1 = {'key1' : ['abc','aa','aa','sdf'],
'key2' : ['aa','efg','aa', 'sdf'],
'key3' : ['aa','aa','xyz', 'aa']
}
data2 = {'key': ['abc','efg', 'xyz', 'sdf'],
'msg' : ['happy','mad','smile','great']}
df1= pd.DataFrame(data1)
df2= pd.DataFrame(data2)
