Conversation

phofl

reindexing solves the issue here before dising to iloc

@phoflphofl added IndexingRelated to indexing on series/frames, not to indexes themselvesRegressionFunctionality that used to work in a prior pandas versionlabels Feb 20, 2021
@@ -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):
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Contributor

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):
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jrebackjreback added this to the 1.2.3 milestone Feb 21, 2021
@simonjayhawkins

reindexing solves the issue here before dising to iloc

maybe add words to that effect as a comment in the code

test failure unreleated. restarted job

@phofl

Added something

@@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise LGTM. Thanks @phofl

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx

@jrebackjreback merged commit 88bcd2d into pandas-dev:master Feb 22, 2021
@jreback

thanks @phofl

@jreback

@meeseeksdev backport 1.2.x

meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Feb 22, 2021
@phoflphofl deleted the 39931 branch February 22, 2021 23:06
simonjayhawkins pushed a commit that referenced this pull request Feb 23, 2021
…igning rhs with boolean indexer) (#39979)

Co-authored-by: patrick <[email protected]>
Sign up for free to join this conversation on . Already have an account? Sign in to comment
IndexingRelated to indexing on series/frames, not to indexes themselvesRegressionFunctionality that used to work in a prior pandas version
None yet

Successfully merging this pull request may close these issues.

BUG: Index alignment behaviour