Skip to content

BUG: np_can_hold_element raising for numpy_dtype and ea Series #47776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
phofl opened this issue Jul 18, 2022 · 3 comments
Open
3 tasks done

BUG: np_can_hold_element raising for numpy_dtype and ea Series #47776

phofl opened this issue Jul 18, 2022 · 3 comments
Labels
Bug ExtensionArray Extending pandas with custom dtypes or arrays. Internals Related to non-user accessible pandas implementation

Comments

@phofl
Copy link
Member

phofl commented Jul 18, 2022

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()

@phofl phofl added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 18, 2022
@jbrockmendel
Copy link
Member

The annotation dtype: np.dtype is correct: EA dtypes should not be passed here.

The annotation element: Any is not correct: Series objects should already have been unpacked here i think. (i guess unless we're treating it as a scalar to potentially set into an object-dtype array?)

@phofl
Copy link
Member Author

phofl commented Jul 20, 2022

So we should always pass Series._values instead of the Series itself?

@jbrockmendel
Copy link
Member

So we should always pass Series._values instead of the Series itself?

im pretty sure that can't be right in the general case, since we could be trying to set a Series object as an entry into an object-dtype array.

@mroeschke mroeschke added Internals Related to non-user accessible pandas implementation ExtensionArray Extending pandas with custom dtypes or arrays. and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug ExtensionArray Extending pandas with custom dtypes or arrays. Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

No branches or pull requests

3 participants