-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix left join turning into outer join #19624
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
01355d5
BUG: Fix 'left' join turned into 'outer' join when joining with a seq…
elrubio d1a85e4
TST: Check for correct index after left-joining a sequence of datafra…
elrubio 6eb27ab
Test fixture removed, using assert_frame_equal
elrubio 0a068a0
Mention bug in release notes
elrubio 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
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 |
---|---|---|
|
@@ -31,6 +31,11 @@ def right(): | |
return DataFrame({'b': [300, 100, 200]}, index=[3, 1, 2]) | ||
|
||
|
||
@pytest.fixture | ||
def right_non_unique(): | ||
return DataFrame({'c': [400, 500, 600]}, index=[2, 2, 4]) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"how, sort, expected", | ||
[('inner', False, DataFrame({'a': [20, 10], | ||
|
@@ -165,3 +170,11 @@ def test_join_period_index(frame_with_period_index): | |
index=frame_with_period_index.index) | ||
|
||
tm.assert_frame_equal(joined, expected) | ||
|
||
|
||
def test_join_left_sequence_non_unique_index(left, right, right_non_unique): | ||
# left join sequence of dataframes with non-unique indices (issue #19607) | ||
joined = left.join([right_non_unique], how='left') | ||
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. Could you also build the expected output and 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. That should definitely be possible |
||
tm.assert_index_equal( | ||
joined.index.unique().sort_values(), | ||
left.index.sort_values()) |
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.
Why'd you make this a fixture? If it's only used in one place then I'd prefer it be defined where it's used.
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.
Well, the below test is just the bare minimum, I think
test_join
needs to cover many more situations. But I will pull it into the method for now.