-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: merge between partial index and index fails when result is empty #34414
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
Changes from 12 commits
49f864a
e4da7c5
1440bce
c0da36e
b9b47c5
c32928d
1922fb9
783af3a
17cba7c
d396576
af000ea
647bbc3
2d22b80
28557c6
efc6eb1
d5d6c8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2234,3 +2234,15 @@ def test_categorical_non_unique_monotonic(n_categories): | |
index=left_index, | ||
) | ||
tm.assert_frame_equal(expected, result) | ||
|
||
|
||
def test_merge_empty_right_index_left_on(): | ||
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. can you do the exact reverse as well and parameterize over it (e.g. left_index=True) 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. We are already testing both cases, parametrization is not really feasible here because we have to switch the dataframes too. |
||
# GH 33814 | ||
df1 = pd.DataFrame({"a": [1], "b": [2]}).set_index(["a", "b"]) | ||
df2 = pd.DataFrame({"b": [1]}).set_index(["b"]) | ||
expected = pd.DataFrame({"a": [], "b": []}, dtype=np.int64).set_index(["a", "b"]) | ||
result = pd.merge(df1, df2, left_on=["b"], right_index=True) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
result = pd.merge(df2, df1, left_index=True, right_on=["b"]) | ||
tm.assert_frame_equal(result, expected) |
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.
move to 1.3
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.
Done