Skip to content

Index/Series Convergence #17061

Closed
Closed
@jbrockmendel

Description

@jbrockmendel

There has been some discussion in #8162 and pandas2#17 about making Index behave more like a regular Series or DataFrame column(s). Is there a consensus towards moving in that direction? In particular, I'm thinking about:

  • DatetimeIndex, PeriodIndex, TimedeltaIndex could have a property dt that returns self. Then users can access foo.dt without having to check whether foo is a Series or Index.

  • If StringAccessorMixin is deprecated (which can be done with a tiny subset of WIP: Refactor accessors, unify usage, make "recipe" #17042), Index can have _accessors, _dir_deletions, and _dir_additions copy/pasted from Series.

  • Less obvious so more of an implied question: Index.map seems to behave a lot like Series.apply and less like Series.map. Any reason not to alias Index.apply = Index.map?

Related Index/MultiIndex compat, a non-multi Index could have self.levels = [self], so users can iterate over levels without pre-checking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignNeeds DiscussionRequires discussion from core team before further action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions