-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
REF: only fallback to masked op for object dtype #40728
REF: only fallback to masked op for object dtype #40728
Conversation
local_dict={"a_value": a_value, "b_value": b_value}, | ||
casting="safe", | ||
) | ||
except TypeError: |
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.
Catching the error here, instead of higher op in _na_arithmetic_op
, ensures that we try again with the plain standard op
instead of directly try again with _masked_arith_op
just ran all the tests asserting that we only get here with object dtype, and found that the failures were floordiv/rfloordiv (handled by #40727) and operator.pow (note: not the same object as |
See my inline comment at https://github.com/pandas-dev/pandas/pull/40728/files#r605632277, that's handling the integer |
Now, there are still some failures in |
sounds good. also looks like with this we can get rid of the last usage of maybe_upcast_putmask |
It was actually a bug in my change in the reversing of the operands |
thanks @jorisvandenbossche |
While investigating #40727, I noticed that we are often trying
_masked_arith_op
, while it will end up giving the exact same error (for example when using ints, which don't have NaNs).From what I understand, I think that, in theory, we only need to fallback to a masked version of the op when having object dtype (I might be wrong here, though). So this PR tries that.
For numeric dtypes, all operations should simply work with NaNs?
For object dtype, we can have NaN or None, which doesn't necessarily work out of the box, so here we need to fallback to a masked operation.
ExtensionArrays don't end up here, and datetimelike dtypes get wrapped into EAs before getting here.