I have 2 DataFrame, I want to add a column in second DataFrame based on multiple (In my case 2) matched column of both DataFrame I tried the code below, but I don't get the right answer. Can anyone help me please?
result = result.merge(out[out['COL1.']!=''].drop(['month'], axis=1), on=['COL1.'], how='left').merge(out[out['month']!=''].drop(['COL1.'], axis=1), on=['month'], how='left')
df1:
COL1. count month
1 Plassen 1293 4
2 Adamstuen 567 4
3 AHO. 1799 5
4 Akersgata 2418 4
df2 :
station month
1 Plassen 4
2 Adamstuen 4
3 AHO. 5
4 Akersgata. 6
What I want is :
station month. count
1 Plassen 4. 1293
2 Adamstuen 4. 567
3 AHO. 5. 1799