Skip to content

ENH: rank() should return 0 indexed values for consistency #46964

@lcrmorin

Description

@lcrmorin

Is your feature request related to a problem?

I am using pandas for a ranking task. The default series.rank() method returns ranks that starts at 1 instead of 0. Thus breaking some unexpected stuff if assuming 0 indexed result, as is common in python.

Describe the solution you'd like

Series.rank() should return 0 indexed values.

API breaking implications

Breaking existing code that rely on 1-indexed ranks

Describe alternatives you've considered

Shifting the output by -1 is the obvious solution, but feels weird.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignAlgosNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffEnhancementNeeds 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