-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: allow DataFrame.rename to take a list-like of colums #14829
Comments
note that |
Yeah, it's a bit odd - I actually could make [5] below work - but at best confusing next to [4] In [1]: s = pd.Series(['a', 'b'])
In [2]: s
Out[2]:
0 a
1 b
dtype: object
In [3]: s.rename('my_series')
Out[3]:
0 a
1 b
Name: my_series, dtype: object
In [4]: s.rename((1,2))
Out[4]:
0 a
1 b
Name: (1, 2), dtype: object
In [5]: s.rename([1,2])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
TypeError: Series.name must be a hashable type |
There is also the idea to call this |
Thanks @jorisvandenbossche - although I'm a little wary of adding another DataFrame method, I am in favor of calling this |
fully agree, but the double use case of |
From @toobaz in #16990 (comment):
I would add that |
Could we do an up / down vote on: a. Adding I'm +1 on |
So I would be ok with
|
another possibility is |
OK. We should add the support for mappings, callables, and I'm quite indifferent between |
[to Does anybody disagree on this? (regardless of whether we then want to rename |
good to deprecate on that. pls add a sub-section in the docs (both whatsnew and maybe in main docs) on what do (e.g. use |
I am -1 on moving towards But maybe that is more a naming question, and the actual proposal is good apart from the name (I still have to go a bit more through all the notifications and discussion after my holidays :-)) |
Some options: I think we'd like to deprecate One proposal is to enhance Another issue is to add a |
We could definitely do this, but The other reason for adding Unfortunately, we have already conflated the concept of "name" in Given the poor alternatives, I think my preferred choice would be to stick with the existing API, where |
@shoyer thanks. Do you have any thoughts on adding a |
This is closely related to #12392, but I think separate issue. Proposal would be to be able to pass a list-like to
DataFrame.rename
to make method-chaining easier. I think it would also be consistent with #11980 (Series rename)The text was updated successfully, but these errors were encountered: