-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: right merge not preserve row order (#27453) #27762
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
Closed
bongolegend
wants to merge
24
commits into
pandas-dev:master
from
bongolegend:27453-right-merge-order
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
c3565c7
add failing test to check row order preservation
0e481a7
correct the imports
42eaad1
change order of args in test assertion
3bba941
broken commit with a bunch of print statements and comments
803243c
add test for left merge
cc269f3
swap left and right keys when how == "right"
f2249df
correct old test: right-merge row order is now the same as the right df
5f728a4
clean up spacing and delete temp code
7ccebb2
add whatsnew
90984e4
replace .from_records with default constructor
de44eae
add GH issue # to tests
a8954fe
revert commit ed54bec7e
d328470
change logic to swap left and right if how==right
3c1a7cb
clean formatting
7fc6441
rename vars and add comment for clarity
1e9df2b
combine tests into one
d017bd5
update whatsnew
71736b8
Update doc/source/whatsnew/v1.0.0.rst
11ec7d0
add before and after examples
c238b50
linting
e29ed1c
cleanup
2b1b675
changes requested by jreback
ef14ba0
update docs
978f91f
Merge branch 'master' into 27453-right-merge-order
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -300,6 +300,30 @@ New repr for :class:`~pandas.arrays.IntervalArray` | |
|
||
pd.arrays.IntervalArray.from_tuples([(0, 1), (2, 3)]) | ||
|
||
:meth:`DataFrame.merge` preserves right frame's row order | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
:meth:`DataFrame.merge` now preserves right frame's row order when executing a right merge (:issue:`27453`) | ||
|
||
.. code-block:: python | ||
|
||
left_df = pd.DataFrame({"colors": ["blue", "red"]}, index=pd.Index([0, 1])) | ||
right_df = pd.DataFrame({"hats": ["small", "big"]}, index=pd.Index([1, 0])) | ||
left_df | ||
right_df | ||
|
||
*pandas 0.25.x* | ||
|
||
.. code-block:: python | ||
left_df.merge(right_df, left_index=True, right_index=True, how="right") | ||
|
||
|
||
*pandas 1.0.0* | ||
|
||
.. code-block:: python | ||
left_df.merge(right_df, left_index=True, right_index=True, how="right") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let this execute (don't put the results in) |
||
|
||
|
||
|
||
``DataFrame.rename`` now only accepts one positional argument | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
show these as well, call then just left and rigth