-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: join/merge of DataFrame does not keep order of index #40608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I believe this bug occurs when there are duplicate entries in the index of the caller. Can test this as follows (Pandas 1.3.2):
Resulting index out of order above, compared to
We retain the original index as expected. |
Similar unexpected behavior is observed when using how = "outer"
Output
Expectation is that v2_unsorted.index index is generated by merge when sort = False ( what is by defaut) |
The issue may be related to issue #34133
Code Sample, a copy-pastable example
Problem description
The index of the joined (or merged) dataframe is not the same as the left hand dataframe even though sort=False.
Expected Output
I would expect the index of the joined/merged dataframe to be the same as the left hand dataframe.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : f2c8480
python : 3.9.0.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.18362
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : French_Belgium.1252
pandas : 1.2.3
numpy : 1.20.1
pytz : 2021.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 49.2.0
The text was updated successfully, but these errors were encountered: