Skip to content

ENH: Disable sorting groups by default in groupby #62414

@asemptote

Description

@asemptote

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

The default sorting of groups is not relevant for most use cases and adds significant overhead for large dataframes. I find myself adding sort=False more often than not and am wondering if other users have a similar experience. As a rule of thumb, functions should reasonably do the minimum work needed by default and leave overhead functionality to non-default flags.

Feature Description

In pandas/core/frame.py#L9155:

def groupby(..., sort: bool = False, ...):
    ...

Alternative Solutions

from functools import partial

partial(df.groupby, sort=False)

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions