I have a 4 df's:
df1
a b
1 0 3
2 1 4
df2
a b
1 0 5
2 0 6
3 1 7
df3
a b
1 0 2
2 1 6
3 1 5
...
Within groups of 'a' I want to merge all 4 df's on a and keep all values by putting them in a further column. The merge of df1 and df2 should look like:
a b1 b2
1 0 3 5
2 0 3 6
3 1 4 7
Merge of df1, df2, df3:
a b1 b2 b3
1 0 3 5 2
2 0 3 6 2
3 1 4 7 6
4 1 4 7 5
I tried:
df1.assign(dummy=1).merge(df2.assign(dummy=1), on='dummy', how='outer').drop('dummy', axis=1)
but this is ignoring the groups and 'a' disappears.