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.
BUG/Perf: Support ExtensionArrays in where #24114
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/Perf: Support ExtensionArrays in where #24114
Changes from 10 commits
c4604df
56470c3
6f79282
a69dbb3
911a2da
badb5be
edff47e
4715ef6
d90f384
5e14414
e9665b8
033ac9c
1271d3d
9e0d87d
e05a597
796332c
cad0c4c
6edd286
30775f0
4de8bb5
ce04a75
f98a82c
bcfb8f8
8d9b20b
c0351fd
539d3cb
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.
The other implementations of
where
(DataFrame.where
,Index.where
, etc.) haveother
default to NA. Do we want to maintain that convention here too?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 this turns it into an array. we have much special handling for this (e.g. see .where for DTI). i think this needs to dispatch somehow.
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.
oh I see you override things. ok then.
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.
Would be nice to have
IntervalIndex
use this implementation instead of the naive object array based implementation that it currently uses. Can certainly leave that for a follow-up PR though, and I'd be happy to do it.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.
To be safe, I think this should be
lother = rother = self.left._na_value
to ensure that we're fillingleft
/right
with the correct NA value. If we useleft/right.where
instead ofnp.where
this should be handled automatically iirc, so could maybe just do that instead.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 make this an
elif
that checks thatother
is interval-like (something likeisinstance(other, Interval) or is_interval_dtype(other)
), then have anelse
clause that raises aValueError
sayingother
must be interval-like?As written I think this would raise a somewhat unclear
AttributeError
inself._check_closed_matches
since it assumesother.closed
exists.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.
left
/right
should have awhere
method, so might be a bit safer to do something like:np.where
looks like it can cause some problems depending on whatleft
/right
are: