Skip to content

BUG: CategoricalIndex can't be a boolen mask #22665

@TomAugspurger

Description

@TomAugspurger
In [1]: import pandas as pd

In [2]: idx = pd.CategoricalIndex([True, False, True])

In [3]: pd.Series(range(3))[idx]
Out[3]:
True    NaN
False   NaN
True    NaN
dtype: float64

Expected:

In [4]: pd.Series(range(3))[idx.astype(object)]
Out[4]:
0    0
2    2
dtype: int64

Fix coming shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CategoricalCategorical Data TypeDtype ConversionsUnexpected or buggy dtype conversionsIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions