You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In [68]:
pd.merge(df1, df2, how='outer', left_index=True, left_on='A', right_on='A')
Out[68]:
A B_x C_x D_x B_y C_y D_y
4 A0 B0 C0 D0 B1 A1 B1
7 A1 B1 C1 D1 NaN NaN NaN
7 A2 B2 C2 D2 NaN NaN NaN
7 A3 B3 C3 D3 NaN NaN NaN
5 A5 NaN NaN NaN B5 C5 D5
6 A6 NaN NaN NaN B6 C6 D6
7 A7 NaN NaN NaN B7 C7 D7
When we try the opposite:
In [69]:
pd.merge(df1, df2, how='outer', right_index=True, left_on='A', right_on='A')
Out[69]:
A A_x B_x C_x D_x A_y B_y C_y D_y
0 A0 A0 B0 C0 D0 NaN NaN NaN NaN
1 A1 A1 B1 C1 D1 NaN NaN NaN NaN
2 A2 A2 B2 C2 D2 NaN NaN NaN NaN
3 A3 A3 B3 C3 D3 NaN NaN NaN NaN
3 4 NaN NaN NaN NaN A0 B1 A1 B1
3 5 NaN NaN NaN NaN A5 B5 C5 D5
3 6 NaN NaN NaN NaN A6 B6 C6 D6
3 7 NaN NaN NaN NaN A7 B7 C7 D7
I'd expect the left_index version to contain the index of the left df or is my understanding incorrect here and the result should be the opposite of the right_index version?
data
With
merge
usingleft_index=True
withouter
:When we try the opposite:
I'd expect the
left_index
version to contain the index of the left df or is my understanding incorrect here and the result should be the opposite of theright_index
version?Version:
There seems to be an inconsistency here and bug with
left_index
version and possibly also theright_index
The text was updated successfully, but these errors were encountered: