Skip to content

BUG: Categorical.values_for_(factorize|argsort) dont preserve order #33245

Open
@jbrockmendel

Description

@jbrockmendel

The docstrings for these two methods say that values_for_foo should preserve order, but for non-ordered Categoricals, the current implementation using self.codes is not order-preserving. Is this a problem cc @jorisvandenbossche ?

Categorical.values_for_rank exists pretty much to solve this problem for rank and value_counts. We have a special case in core.algorithms using values_for_rank that we should ideally avoid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugCategoricalCategorical Data TypeExtensionArrayExtending pandas with custom dtypes or arrays.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions