8000 BUG: Fix value setting in case of merging via index on one side and column on other side. by phofl · Pull Request #34496 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix value setting in case of merging via index on one side and column on other side. #34496

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

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change if condition
  • Loading branch information
phofl committed May 31, 2020
commit a3e6623dcba740bf1a45111257dcb0e082049e7c
44 changes: 21 additions & 23 deletions pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,36 +800,34 @@ def _maybe_add_join_keys(self, result, left_indexer, right_indexer):
or self.left_index is True
and name in self.left.index.names
)
if right_in and left_in or array_like or self.how == "asof":

if left_indexer is not None and right_indexer is not None:
if name in self.left:
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:

if left_has_missing is None:
left_has_missing = (left_indexer == -1).any()
if left_has_missing is None:
left_has_missing = (left_indexer == -1).any()

if left_has_missing:
take_right = self.right_join_keys[i]
if left_has_missing:
take_right = self.right_join_keys[i]

if not is_dtype_equal(
result[name].dtype, self.left[name].dtype
):
take_left = self.left[name]._values
if not is_dtype_equal(
result[name].dtype, self.left[name].dtype
):
take_left = self.left[name]._values

elif name in self.right:
elif name in self.right:

if right_has_missing is None:
right_has_missing = (right_indexer == -1).any()
if right_has_missing is None:
right_has_missing = (right_indexer == -1).any()

if right_has_missing:
take_left = self.left_join_keys[i]
if right_has_missing:
take_left = self.left_join_keys[i]

if not is_dtype_equal(
result[name].dtype, self.right[name].dtype
):
take_right = self.right[name]._values
else:
continue
if not is_dtype_equal(
result[name].dtype, self.right[name].dtype
):
take_right = self.right[name]._values

elif left_indexer is not None and is_array_like(self.left_join_keys[i]):
take_left = self.left_join_keys[i]
Expand Down
0