Skip to content

BUG: find_common_type incorrect for Categorical with NaNs #38240

Open
@jbrockmendel

Description

@jbrockmendel
import pandas as pd
from pandas.core.dtypes.cast import find_common_type

left = pd.Index([1, 2, 3, 4])
right = pd.CategoricalIndex([1, None], categories=left)

dtype = find_common_type([left.dtype, right.dtype])

>>> right.astype(dtype)
ValueError: Cannot convert float NaN to integer

xref #37930; I expect this would also be relevant for #19371

Metadata

Metadata

Assignees

No one assigned

    Labels

    CategoricalCategorical Data TypeDeprecateFunctionality to remove in pandasExtensionArrayExtending pandas with custom dtypes or arrays.Needs DiscussionRequires discussion from core team before further actionPDEP missing valuesIssues that would be addressed by the Ice Cream Agreement from the Aug 2023 sprint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions