-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
API/REGR: (re-)allow neg/pos unary operation on object dtype #21590
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
API/REGR: (re-)allow neg/pos unary operation on object dtype #21590
Conversation
cc @deniederhut For the unary positive, if we care I can check for datetime64 and raise a TypeError for that (although we can also follow numpy's example). For the object dtype (eg strings), that's not really possible since it is exactly the idea to allow it for those types in an object column that allow it. |
code change looks good (though you simply may need to add |
+1. Thoughts on applying the same pass-through approach to |
Do you mean to only specifically call |
I meant more just to extend the if from the original code, like
|
@jorisvandenbossche I pushed a fix to make this work |
yeah, sorry for the delay, getting to it today I am fine with the |
I tried that and it failed your tests :> So maybe they are too strict. I didn't dive too deep here. |
in particular this (on master)
|
Yes, not inferring strings means that we need to update the test (but only for |
Codecov Report
@@ Coverage Diff @@
## master #21590 +/- ##
=========================================
Coverage ? 91.9%
=========================================
Files ? 154
Lines ? 49555
Branches ? 0
=========================================
Hits ? 45542
Misses ? 4013
Partials ? 0
Continue to review full report at Codecov.
|
Yes, I think that is a good idea, but let's leave that for a separate PR / 0.24.0 |
seems numpy allows this which I find odd.
ok with matching numpy (for pos only). |
I think the policy of numpy regarding
Yes (for object dtype now, for datetime we still raise), and for |
thank you sir! |
…dev#21590) (cherry picked from commit 8cb6be0)
(cherry picked from commit 8cb6be0)
closes #21380
This is an easy fix to simply be more forgiveable and just try the operation:
The scalar values (eg strings) already raise an informative error message. Eg for a series with string you get
TypeError: bad operand type for unary -: 'str'
for unary negative operation.+s_string
)Details with examples