Skip to content

BUG: reset_index can reset index name #17067

Closed
@p-himik

Description

@p-himik
import pandas as pd
assert (pd.DataFrame(index=pd.Index([], name='x'))
        .reset_index(level=[]).index.name) is None

The root of the problem is in pandas.core.common._default_index:

def _default_index(n):
    from pandas.core.index import RangeIndex
    return RangeIndex(0, n, name=None)

Probably, a new optional argument name can be introduced to _default_index and used in reset_index.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselvesNeeds TestsUnit test(s) needed to prevent regressionsgood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions