Skip to content

IntegerArray.astype("datetime64[ns]") fails with NAs #32435

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

Closed
jbrockmendel opened this issue Mar 4, 2020 · 0 comments · Fixed by #32538
Closed

IntegerArray.astype("datetime64[ns]") fails with NAs #32435

jbrockmendel opened this issue Mar 4, 2020 · 0 comments · Fixed by #32538
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions ExtensionArray Extending pandas with custom dtypes or arrays.
Milestone

Comments

@jbrockmendel
Copy link
Member

tools.datetimes has to dig into IntegerArray internals in a way that in principle should be handled by IntegerArray.astype

ser = pd.Series(range(2), dtype="Int64")
arr = ser.array

>>> arr.astype("datetime64[ns]")
array(['1970-01-01T00:00:00.000000000', '1970-01-01T00:00:00.000000001'],
      dtype='datetime64[ns]')

arr[-1] = pd.NA

>>> arr.astype("datetime64[ns]")
ValueError: cannot convert to 'datetime64[ns]'-dtype NumPy array with missing values. Specify an appropriate 'na_value' for this dtype.

@jreback jreback added Bug Dtype Conversions Unexpected or buggy dtype conversions ExtensionArray Extending pandas with custom dtypes or arrays. labels Mar 11, 2020
@jreback jreback added this to the 1.1 milestone Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants