-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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: Add various deprecated attributes to ._deprecated #28805
API: Add various deprecated attributes to ._deprecated #28805
Conversation
41d014f
to
a4f6744
Compare
pandas/core/arrays/categorical.py
Outdated
@@ -331,7 +331,7 @@ class Categorical(ExtensionArray, PandasObject): | |||
__array_priority__ = 1000 | |||
_dtype = CategoricalDtype(ordered=False) | |||
# tolist is not actually deprecated, just suppressed in the __dir__ | |||
_deprecations = frozenset(["labels", "tolist"]) | |||
_deprecations = frozenset(["get_values", "tolist"]) |
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.
labels
is no longer an atribute on Categorical.
9e67b09
to
c729d85
Compare
seem fine. Any way to have a systematic test here? I don't necessarly care about the actual tab completion itself (though that would be nice), rather that the list is checked against actual deprecations. An idea: we could parse our doc source for Deprecated and then use that as the source of truth (also could do the same with tests). |
Yeah, I thought about it, but can't think of a method that doesn't parse all the source files, which would be inefficient. Maybe add a class AClass:
@deprecated(hide=True)
def (self, ...):
... But I'm however not personally particularly interested in implementing this, and it should probably be something that is implemented as an independent project outside of pandas anyway... |
c729d85
to
b3705bc
Compare
Could maybe leverage something similar to what I posted in #27353 for AST parsing and check where FutureWarning gets raised, but yea also agree can be done separately |
Hmm actually it would be nice to have something like that as a test here as well otherwise I can see this getting out of sync very fast |
Yeah, I'd like this to exist, I'm just not interested in coding it up myself :-). |
I guess I'd prefer not to do something like this without checks and balances (whether a test or a code check of some sort). Especially if exposing to end users via whatsnew it could add technical debt |
@topper-123 can you give a manual check in ipython to see if everything is working? I agree an automated test would be nice, but not going to block merging this as its a net improvement. |
b3705bc
to
c1b21cb
Compare
I've rechecked, all is ok. I found "reshape" in The oldest deprecated name I found was |
I notice I said I was What I meant was that it seems a bit big of a undertaking relative to the benefits IMO, so I don't feel it is worth it to spend time on, relative to other PR...If someone else would like to take it on, I'd be positive to the change. |
Ha all good - I understood what you were trying to say. I've flip flopped on the issue so also not a blocker for me, just figured was worth thinking twice about |
Is this ok? |
Looks good to me. I agree that a full blown test is not worth to block this. I was just thinking, an easy test to keep a bit track of this might be to thest that all elements in |
That's a a very small win IMO, because if the attribute doesn't exist, there's not really any loss from the string existing in
Neither which are trivial to test for IMO. |
thanks @topper-123 ok we will have to be vigilant to add things when they are deprecated. |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
This add various deprecated attributes to their respective types'
_deprecated
. The effect is that these are now also hidden when tab-completing, making navigating the pandas attributes easier.