-
-
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
BUG: join on column with index #49360
Conversation
…243_bug_join_leftindex_righton
…243_bug_join_leftindex_righton
…on' into gh28243_bug_join_leftindex_righton
…243_bug_join_leftindex_righton
…243_bug_join_leftindex_righton
…on' into gh28243_bug_join_leftindex_righton
…on' into gh28243_bug_join_leftindex_righton
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.
Cool thanks for giving this a shot. Not sure about the changed tests - so you think all of these exhibit buggy behavior?
if (self.left_index and not self.right_index) or ( | ||
self.right_index and not self.left_index | ||
): | ||
if key_col.equals(result.index): |
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
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
this would fail.. since to_join
is being joined on the index.. the final df would contain that index
this behaviour is mentioned in the docs for merge
.. but since join also uses most of the same stuff.. I think they should be consistent?!
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.
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 comment
The 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:
- In merge, with column on one side and index on the other, the result inherits the index from the data frame merged on the index (edit: this behaviour is as per doc)
- Since join uses merge, I think their output should be consistent with each other
Most of |
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.
Do all three of these need to be fixed together? I think it would be easier to move forward if we can fix one thing at a time - I'm not sure all these changes are desired
@@ -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 comment
The 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?
All the three bugs are kind of similar. EDIT: Even the two xref bugs are similar. But I am not very sure about the expected dfs from those. |
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |
(below can be closed if agree on expected result)
xref #28220
xref #33232
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Lot's of existing tests were changed, i think there are multiple reported bugs on this.. I might be missing a few others as well.
The changed tests could be broadly classified as:
The data type of the expected df was object instead of say datetime, or someotherIn merge_asof I think since it defaults to left join, it should inherit the index from left df(these are working fine, there was some trouble with local build initially)One particular test, which I am little puzzled about the expected output is the below. Joining on index on one df, and partial index and partial column in the other df. I was not able to figure out, so skipped for the time
pandas/pandas/tests/reshape/merge/test_merge_index_as_string.py
Lines 166 to 189 in f9ff379