-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
DEPR: deprecate raise_on_error in .where/.mask in favor of errors= #17744
Conversation
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 PR itself looks good, added some minor comments.
But more in general, can you actually give a use case ? I mean a small example where you see the effect of the keyword?
I haven't been able to make one, and it also seems you didn't have to change any test (the one test you changed, there the keyword has no effect at all). Just wondering, probably I am missing something, but if not I would rather deprecate completely without adding alternative.
return the results | ||
errors : str, {'raise', 'ignore'}, default 'ignore' | ||
'raise' : pass the error to the higher level | ||
'ignore' : evaluate the op with and return the results |
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 know it was like this before, but for me the phrase "evaluate the op with" is not really clear what it means
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.
yeah a bunch of copy-paste
pandas/core/generic.py
Outdated
|
||
if raise_on_error is not None: | ||
warnings.warn( | ||
"raise_on_error is deprecated in favor of errors='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.
the 'raise' is only for setting it to True, not False, so I would mention both options
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 right
assert_series_equal(result, expected) | ||
|
||
result = s.where([True, False], | ||
Timestamp('20130101', tz='US/Eastern'), | ||
raise_on_error=True) | ||
errors='ignore') |
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.
What is the difference between both of the above cases ?
(also , the errors
has no effect)
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.
right the kw is pretty much ignored in .where (that's part of the problem); its used in other routines. This is pretty much a mess internally, though making progress.
this really doesn't change anything; just had to fix some actual calls that causes the deprecation warning. The point of this is make things consistent. In the future I actually do want to change the defaults I think (and make 'coerce') possible. This is just conforming things a bit. |
I know this PR is not changing things, it is just converting the previous situation to a new more consistent one. That is fine. But if it is really a useless keyword, it is also an opportunity to clean things up, and to not just translate the mistakes (?) of the previous keyword to the new one. Maybe I am missing something, but so my question still is: is there a case |
We DO need this, it is just not fully working ATM; it was turned off a while back. We need the option to raise, or ignore where the dtype is actually changing (rather than just do it, or in some cases coerce), this is a very common choice which we do in lots of places. I don't think its a big deal to add the kw. Sure I can prob only allow 'raise' for now. Though we DO need it in a couple of places. |
Codecov Report
@@ Coverage Diff @@
## master #17744 +/- ##
==========================================
- Coverage 91.24% 91.2% -0.05%
==========================================
Files 163 163
Lines 49962 49973 +11
==========================================
- Hits 45588 45576 -12
- Misses 4374 4397 +23
Continue to review full report at Codecov.
|
this should be much cleaner now. final thoughts...... @jorisvandenbossche @TomAugspurger |
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.
+1 for doing this now, if it makes things easier in the future.
pandas/core/internals.py
Outdated
- ``raise`` : allow exceptions to be raised | ||
- ``ignore`` : suppress exceptions. On error return original object | ||
|
||
values : |
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 an unfinished docstring here.
I am fine with having the keyword, I would just update the actual docstring (of the user facing where and mask) to not be misleading (as the current explanation is not correct). I didn't follow the earlier discussion (#16821), but just to clarify: what is the idea with |
well the problem is we are effectively always Now we just up-convert to |
updated. |
closes #14968