-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Add method to change the .name attribute on the axes #11965
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
I've written up a PR for this a couple times, before discarding it, mostly since I'm +.5 on adding these methods or something like them. I don't think we should add anything to |
this is related to #9494 |
if we implement soln for #10797 then you could do:
(though missing ability to set_columns atm, so only works for index) |
I'll put something together for this and #9494 |
@jreback the Haven't tried it, but I guess another (pretty verbose) strategy would be to use |
closes pandas-dev#9494 closes pandas-dev#11965 Okay refactored to overload `NDFrame.rename` and `NDFrame.rename_axis` New rules: - Series.rename(scalar) or Series.rename(list-like) will alter `Series.name` - NDFrame.rename(mapping) and NDFrame.rename(function) operate as before (alter labels) - NDFrame.rename_axis(scaler) or NDFrame.rename_axis(list-like) will change the Index.name or MutliIndex.names - NDFrame.rename_axis(mapping) and NDFrame.rename_axis(function) operate as before. I don't like overloading the method like this, but `rename` and `rename_axis` are the right method names. It's *mostly* backwards compatible, aside from people doing things like `try: series.rename(x): except TypeError: ...` and I don't know what our guarantees are around things like that. Author: Tom Augspurger <[email protected]> Closes pandas-dev#11980 from TomAugspurger/chainable-rename and squashes the following commits: b36df76 [Tom Augspurger] ENH/API: Series.rename and NDFrame.rename_axis
It would be nice to have a method to change the
.name
attribute on the columns/index, to permit it in a method chain. (This is a suggestion based on this stackoverflow question.)Instead of
it would allow something like
or perhaps be a keyword argument to the existing
.rename()
. Does this seem like something that would fit in with pandas?The text was updated successfully, but these errors were encountered: