df1 = pd.DataFrame([['A0', 'A1', 'A2', 'A3'],
['B0', 'B1', 'B2', 'B3'],
['C0', 'C1', 'C2', 'C3'],
['D0', 'D1', 'D2', 'D3']], columns=list('ABCD'))
df2 = pd.DataFrame([['A4', 'A5', 'A6', 'A7'],
['B4', 'B5', 'B6', 'B7'],
['C4', 'C5', 'C6', 'C7'],
['D4', 'D5', 'D6', 'D7']], columns=['A', 'B', 'C', 'D'], index=[4, 5, 6, 7])
df3 = pd.DataFrame([['A8', 'A9', 'A10', 'A11'],
['B8', 'B9', 'B10', 'B11'],
['C8', 'C9', 'C10', 'C11'],
['D8', 'D9', 'D10', 'D11']], columns=list('ABCD'), index=[8, 9, 10, 11])
left = pd.DataFrame({'key': ['K0', 'K4', 'K2', 'K3'],
'A': ['A0', 'A4', 'A2', 'A3'],
'B': ['B0', 'B4', 'B2', 'B3']})
right = pd.DataFrame({'key': ['K0', 'K1', 'K2', 'K3'],
'D': ['D0', 'D1', 'D2', 'D3']})
df1 = pd.DataFrame({'id':['K001','K002','K003'],
'A':['A0','A1','A2'],
'B':['B0','B1','B2']}
)
tidy1 = df1.melt(id_vars = 'id', value_vars = ['A', 'B'])