Skip to content

REF: avoid try/except in Block.where #37802

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

Merged
merged 3 commits into from
Nov 13, 2020
Merged

Conversation

jbrockmendel
Copy link
Member

No description provided.

try:
result = where_func(cond, values, other)
except TypeError:
if self.is_bool and lib.is_float(other) and np.isnan(other):
Copy link
Contributor

Choose a reason for hiding this comment

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

prob can lif this to one higher level (and the elif below)

Copy link
Member Author

Choose a reason for hiding this comment

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

i think that would take some gymnastics to avoid having the L1455-1456 cases fall through to the expressions.where call

Copy link
Contributor

Choose a reason for hiding this comment

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

sure can be a followup

try:
result = where_func(cond, values, other)
except TypeError:
if self.is_bool and lib.is_float(other) and np.isnan(other):
Copy link
Contributor

Choose a reason for hiding this comment

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

does this include self.integer (e.g. the same case you have on L1474)

Copy link
Member Author

Choose a reason for hiding this comment

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

changing the self.is_bool to (self.is_integer or self.is_bool) here doesn't break any tests, and i guess going through expressions may be more performant (though im not wild about the casting being not-super-obvious). will update.

@jreback jreback added Internals Related to non-user accessible pandas implementation Refactor Internal refactoring of code labels Nov 13, 2020
@jreback jreback added this to the 1.2 milestone Nov 13, 2020
@jreback jreback merged commit 25f9b4e into pandas-dev:master Nov 13, 2020
@jreback
Copy link
Contributor

jreback commented Nov 13, 2020

thanks, some comments for followon

@jbrockmendel jbrockmendel deleted the cln-wheres branch November 13, 2020 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internals Related to non-user accessible pandas implementation Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants