Suppose:
>>> df1 = pd.DataFrame({"A":[1,2,3],"B":[2,4,6]})
>>> df1
A B
0 1 2
1 2 4
2 3 6
and:
>>> df2 = pd.DataFrame({"A":[1,1,2,2,3,3, 4],"B":[2,3,4,5,6,7, 8], "C":[11,12,13,14,15,16, 17]})
>>> df2
A B C
0 1 2 11
1 1 3 12
2 2 4 13
3 2 5 14
4 3 6 15
5 3 7 16
6 4 8 17
I expect to combine them and have the following where I have complete values of df2
for common rows on A
:
A B C
0 1 2 11
1 1 3 12
2 2 4 13
3 2 5 14
4 3 6 15
5 3 7 16
what I tried:
>>> df2.merge(df1, how='outer')
A B C
0 1 2 11
1 1 3 12
2 2 4 13
3 2 5 14
4 3 6 15
5 3 7 16
6 4 8 17
Maybe I don't want merge,two dataframes are identical on columns, but one have more rows and more targets for some keys (keys are in A, and targets are B), I want all targets for keys on df1... I tried varies on and how options, none of them were my answer, unless you point it. Otherwise, the other question isn't helpful here