-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: join on column with index #49360
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 33 commits
4bf58bd
f4f84f4
00e87ba
a0f6d76
e89cacb
35a4b5d
20add1c
a324be7
eeae11b
f824d73
d95515c
a8c78a0
751e882
4110e2b
66dfff4
c3e5fd2
86fc699
6f6021d
f18b2d2
15f3c9f
a9760ff
f096c0c
aa8ac6d
b1b2ac7
f37d3b4
1cfa627
8dcb0bc
a9b8412
95741d7
ca1e1ed
ced3c5b
76b9310
1c83099
9c28ecf
81ace15
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 |
---|---|---|
|
@@ -231,6 +231,7 @@ def test_join_on_inner(self): | |
|
||
expected = df.join(df2, on="key") | ||
expected = expected[expected["value"].notna()] | ||
expected.index = expected.key.values | ||
tm.assert_series_equal(joined["key"], expected["key"]) | ||
tm.assert_series_equal(joined["value"], expected["value"], check_dtype=False) | ||
tm.assert_index_equal(joined.index, expected.index) | ||
|
@@ -415,7 +416,7 @@ def test_join_inner_multiindex(self, lexsorted_two_level_string_multiindex): | |
expected = expected.drop(["first", "second"], axis=1) | ||
expected.index = joined.index | ||
|
||
assert joined.index.is_monotonic_increasing | ||
# assert joined.index.is_monotonic_increasing | ||
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 revert this? 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. this would fail.. since this behaviour is mentioned in the docs for 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. Hmm not sure I follow - what does this produce now? Why does the monotonicity of the index change? 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. Previously joined inherited the index from data df. After the change it will inherit from tojoin. My reason for this to be expected:
|
||
tm.assert_frame_equal(joined, expected) | ||
|
||
# _assert_same_contents(expected, expected2.loc[:, expected.columns]) | ||
|
@@ -661,11 +662,13 @@ def test_join_multi_to_multi(self, join_type): | |
right = DataFrame({"v2": [100 * i for i in range(1, 7)]}, index=rightindex) | ||
|
||
result = left.join(right, on=["abc", "xy"], how=join_type) | ||
expected = ( | ||
left.reset_index() | ||
.merge(right.reset_index(), on=["abc", "xy"], how=join_type) | ||
.set_index(["abc", "xy", "num"]) | ||
expected = left.reset_index().merge( | ||
right.reset_index(), on=["abc", "xy"], how=join_type | ||
) | ||
if join_type == "left": | ||
expected = expected.set_index(["abc", "xy", "num"]) | ||
else: | ||
expected = expected.set_index(["abc", "xy"]).drop("num", axis=1) | ||
tm.assert_frame_equal(expected, result) | ||
|
||
msg = r'len\(left_on\) must equal the number of levels in the index of "right"' | ||
|
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.
Might be misreading this but what is the point of this loop? Only ever continues?
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.
this would hit continue, only when it's merging on a col and an index and index already contains correct values