-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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: Fix value setting in case of merging via index on one side and column on other side. #34496
Changes from all commits
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 |
---|---|---|
|
@@ -787,7 +787,25 @@ def _maybe_add_join_keys(self, result, left_indexer, right_indexer): | |
take_left, take_right = None, None | ||
|
||
if name in result: | ||
|
||
array_like = is_array_like(rname) or is_array_like(lname) | ||
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. what are you trying to do here? 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. If you mean only line 790: If an array is given as join key, then this should be handled like a column. So we have to set the values into the result. Generally this block should handle the following: If we join an index with an column this part sets the index values as the column values in the result DataFrame. To avoid this I check if we should run in there. We should only run in there if both DataFrames are joined via the same columns, if a array was given as join condition. Actually I realised that the condition with the index is crap. That would keep the initial problem if the index is accidentally named as the join column. This will break a few more tests unfortunately. |
||
right_in, left_in = False, False | ||
if not array_like: | ||
right_in = ( | ||
name in self.right_on | ||
or self.right_index is True | ||
and name in self.right.index.names | ||
) | ||
left_in = ( | ||
name in self.left_on | ||
or self.left_index is True | ||
and name in self.left.index.names | ||
) | ||
if ( | ||
(not right_in or not left_in) | ||
and not array_like | ||
and self.how != "asof" | ||
): | ||
continue | ||
if left_indexer is not None and right_indexer is not None: | ||
if name in self.left: | ||
|
||
|
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.
I have no idea what you are trying to fix by reading this. You are xrefing lots of issues, are you actually closing them?
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.
The issues have to different problems.
1: The index is not handled right
2: The values of the join columns are wrong.
This PR fixes 2, #34468 should fix the other part. That is why I am only referencing them.