-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix regression for setitem not aligning rhs with boolean indexer #39944
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
Conversation
@@ -3263,6 +3263,8 @@ def _setitem_array(self, key, value): | |||
key = check_bool_indexer(self.index, key) | |||
indexer = key.nonzero()[0] | |||
self._check_setitem_copy() | |||
if isinstance(value, DataFrame): |
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.
does series hit this path?
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.
No, I did this because value could be an array for example
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.
ok great
@@ -566,3 +566,11 @@ def test_setitem_boolean_mask(self, mask_type, float_frame): | |||
expected = df.copy() | |||
expected.values[np.array(mask)] = np.nan | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
def test_setitem_boolean_mask_aligning(self): |
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 parameterize over .loc & setitem
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
maybe add words to that effect as a comment in the code test failure unreleated. restarted job |
� Conflicts: � doc/source/whatsnew/v1.2.3.rst
Added something |
pandas/core/frame.py
Outdated
@@ -3264,6 +3264,9 @@ def _setitem_array(self, key, value): | |||
key = check_bool_indexer(self.index, key) | |||
indexer = key.nonzero()[0] | |||
self._check_setitem_copy() | |||
if isinstance(value, DataFrame): | |||
# GHä39931 reindex since iloc does not align |
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.
typo
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.
otherwise LGTM. Thanks @phofl
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.
Thx
thanks @phofl |
@meeseeksdev backport 1.2.x |
… rhs with boolean indexer
…igning rhs with boolean indexer) (#39979) Co-authored-by: patrick <[email protected]>
reindexing solves the issue here before dispatching to iloc