Skip to content

ENH: Add column_name parameter to DataFrame.reset_index #47455

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
jachymb opened this issue Jun 22, 2022 · 1 comment
Closed

ENH: Add column_name parameter to DataFrame.reset_index #47455

jachymb opened this issue Jun 22, 2022 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request Enhancement

Comments

@jachymb
Copy link

jachymb commented Jun 22, 2022

Describe the solution you'd like

When I run DataFrame.reset_index and transform the index to a new column this way (using drop=False) the new column seems to be hardcoded to be called 'index'. But I want it to be named like 'MyTable_ID'. I suggest DataFrame.reset_index has an optional parameter column_name with the default value 'index'.

API breaking implications

The proposed change introduces a new optional parameter and is fully backwards compatible.

Describe alternatives you've considered

Can simply use df.rename('index', 'MyTable_ID', inplace=True) as a workaround.

Additional context

May need some extra care when dealing with multiindex.

@jachymb jachymb added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 22, 2022
@phofl
Copy link
Member

phofl commented Jun 22, 2022

Hi, thanks for your report. This was added in #46167

@phofl phofl closed this as completed Jun 22, 2022
@phofl phofl 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 22, 2022
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

2 participants