Skip to content

ENH: Give name to index column as argument when using df.reset_index #41947

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

Closed
gcaria opened this issue Jun 11, 2021 · 2 comments
Closed

ENH: Give name to index column as argument when using df.reset_index #41947

gcaria opened this issue Jun 11, 2021 · 2 comments
Labels
Duplicate Report Duplicate issue or pull request Enhancement

Comments

@gcaria
Copy link
Contributor

gcaria commented Jun 11, 2021

Is your feature request related to a problem?

When resetting the index of a DataFrame, and when needing to rename the "index" column to something more useful, it would be nice to do it directly with the call toreset_index (and not afterwards with df.rename).

Describe the solution you'd like

DataFrame.reset_index should get a new parameter name that renames the "index" column after resetting.

API breaking implications

I don't see any obvious implications.

@gcaria gcaria added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 11, 2021
@jorisvandenbossche
Copy link
Member

I think that would be a good idea, see #6878 (I think we can close this as a duplicate).

The main problem is that Series.reset_index already has a name keyword but that is used for the values column name, not index column name (so we will probably need another keyword name for this, unfortunately)

@jorisvandenbossche jorisvandenbossche added Duplicate Report Duplicate issue or pull request and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 11, 2021
@gcaria
Copy link
Contributor Author

gcaria commented Jun 11, 2021

Totally a duplicate, my bad for not checking properly! I'll have a look at #6878 and see if I can submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants