Skip to content

BUG: CategoricalIndex.get_indexer with  #45361

Closed
@jbrockmendel

Description

@jbrockmendel
ci = pd.CategoricalIndex([1, 2, np.nan, 3])
other = pd.Index([2, 3, 4])

res = ci.get_indexer(other)

>>> res
array([1, 3, 2])

The 4 in other is getting mapped to the nan in ci. Best guess is that this is passing other to the Categorical constructor which will return Categorical([2, np.nan, 3], dtype=ci.dtype). If correct, this would be avoided by #40996.

Expected Behavior

>>> res
array([1, -1, 2])

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugCategoricalCategorical Data TypeMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions