-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: value_counts / shift not in groupby dispatch whitelist (0.12-dev) #5480
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
Comments
This seems like a good idea - would be nice to get a pull-request with tests that exercise the methods that we're readding. |
you can of course use apply and use whatever methods u want this magic of operating on the groupby is only for convience (and possibly cythonized methods) |
That's fair and the exception is clear about using apply instead. Just wanted to file this as it broke existing code without a deprecation warning. |
@jreback wouldn't be too hard to set up a DeprecationWarning for this... def _make_wrapper(self, name):
if name not in _apply_whitelist:
is_callable = callable(getattr(self.obj, name, None))
kind = ' callable ' if is_callable else ' '
warn("access to{0}attribute {1!r} of {2!r} objects is deprecated"
" and will be removed in a future version, try using the"
"'apply' method".format(kind, name, type(self).__name__)) |
@jreback I think we need to do the deprecation first, otherwise people are going to get confused. Are you okay with that? |
sure.. (though i would add shift/value_counts to whitelist as well). only thing with deprecation - i think it needs to be dynamic to avoid having the tab completion (the dir find those methods) |
We could keep the whitelist for dir completions and then use the warning if |
irc their is some kind of message their now.? |
It's an error though right? On Mon, Nov 11, 2013 at 5:19 PM, jreback notifications@github.com wrote:
|
i am confused now that error message is already there i would just add shift and value_counts. not big on other methoods as they should be in the inner apply anyhow (their may be some more exception)....but I think its beter to err on the side of a limited whitelist |
its an AttributeError which is correct, not a Deprecation..... its more explicit to use apply |
I think @gdraps brought this up not only for value_counts/shift, but also because there are probably a few people who relied on some part of this and will be surprised their existing code doesn't work (even if it was buggy/wrong - @gdraps please correct me if I've mischaracterized). We generally deprecate everything before removing it, seems like that's relevant here too. |
ok with the deprecation but u then may need a blacklist that raises for sure - eg to_csv and such |
Okay, @gdraps, do you have time to put this together? |
I took a stab at reviewing the full list of methods and would propose the following be added to the whitelist:
As far as the blacklist goes, am thinking all to_* methods:
When's the target for 0.13? I can put a PR later this week. |
Target is any day now. I'll put up a quick PR to enable the ones you listed. |
median isalready a defined method |
what i mean is tht the whitelist should not include methods which are explicity defined on a groupby (as they are already allowed) |
Yep, that's what I understood, I took off median. |
Copying comment from #4887 to a new issue for discussion purposes:
While testing pandas-master, hit a method not in the new groupby dispatch whitelist:
value_counts
(on aSeriesGroupBy
object). Another possible addition:shift
, as used in this SO answer.Tried to generate a list of blacklisted methods for DataFrame and Series, see below -- needs further filtering, but may reveal useful blocked methods. any thoughts on the remaining methods?
The text was updated successfully, but these errors were encountered: