Skip to content

BUG: np_can_hold_element raising for numpy_dtype and ea Series #47776

Open
@phofl

Description

@phofl

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

from pandas.core.dtypes.cast import np_can_hold_element

# This raises
np_can_hold_element(np.dtype("int64"), Series([1, 2], dtype="Int64"))

# while both of the following work
np_can_hold_element(pd.Int64Dtype, Series([1, 2], dtype="int64"))
np_can_hold_element(pd.Int64Dtype, Series([1, 2], dtype="Int64"))

Issue Description

Using non-ea dtypes and ea-dtype Series objects raises, this should not happen.

Expected Behavior

Should not raise

#47425

Installed Versions

Replace this line with the output of pd.show_versions()

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugExtensionArrayExtending pandas with custom dtypes or arrays.InternalsRelated to non-user accessible pandas implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions