Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
ENH: Enable indexing with nullable Boolean #31591
ENH: Enable indexing with nullable Boolean #31591
Changes from 69 commits
75c915f
9c5b9f0
2441b40
d71d1ba
4d3a264
543ef9a
d3e7a69
ad7ae66
6991394
f6e9ce5
1234407
9b7e879
efdd29a
7fa36b6
b8e3d6b
bc3fe3f
73ad221
547d7bc
5649445
bb3d143
f107252
7b924b7
46d77df
ac71cbf
e5ed092
9fcdb23
c2dfa93
a9a12b1
7c10f33
cf3d60d
157d8b9
250f228
647f0f6
6ccd96d
a9e73de
adc3075
29ff823
0a58605
b38a209
5088cbb
54efdd9
c6b81ed
67800c6
4c334f3
578fd3c
a559385
705947e
4974778
319b525
8007ce4
a10765f
d7fc3b7
bca582e
6f9a298
e1e39fe
5a72b2f
c0e8dc7
a293bc6
607d9ed
2e7f9b3
bfe472b
a6294f8
c6d23f6
c8ee434
fbda99d
3bf9327
dd65b0d
974ec5d
8f2d7bb
080d1d2
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 keep this example but reword it as something like "if you want different behaviour, you can fill manually with fillna(True)" ?
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 comment here seems to indicate that this was also done for sparse data (and not only object dtype data). But no tests are failing? This might need some checking if the comment was outdated (I think it was only recently added)
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 check this comment? (about the sparse from the code comment)
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 able to simply to check_array_indexer right before returning (iow for all cases) here. (try in a followon)
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 take here something with True's as well? (now it will give an empty result)
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.
it would be good to run the test also for both a boolean array and a list as mask (to ensure the list works)
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.
Looks like the list input may not be working properly, will work on fixing that
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.
@jorisvandenbossche So I think the issue with list masks containing bools and pd.NA was that
is_bool_indexer
frompandas/core/common.py
didn't consider these to be valid boolean indexers because it was trying to cast to a bool numpy array: https://github.com/pandas-dev/pandas/blob/master/pandas/core/common.py#L142Made an update there to recognize pd.NA and also updated the test; hopefully CI will still pass. The assumption that boolean indexers are ones that can be cast as numpy boolean arrays seems to happen in a lot of places (e.g., https://github.com/pandas-dev/pandas/blob/master/pandas/core/indexes/base.py#L4147) so I could see this causing problems.
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, the "old" code of still accepting object dtype makes this a bit more complex indeed. Maybe instead of casting to a numpy array, we could use
pd.array
, so it will handle the case with boolean values better?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 think that should theoretically work in combination with the right change to
is_bool_indexer
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.
rather than remove this can you turn it into a test (obviously changed that we no longer raise)
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.
Isn't this test duplicating the
test_setitem_mask
above?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.
Somewhat, yes
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.
You can simply remove it then, I think?
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 we have a setitem test?
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.
Yes, I added a case containing NA to the the
test_setitem_mask
test Joris had merged previously (should be line 101 ofsetitem.py
above)