Skip to content

ENH: Add column_name parameter to DataFrame.reset_index #47455

Closed
@jachymb

Description

@jachymb

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions