Skip to content

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

Closed
@jbrockmendel

Description

@jbrockmendel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsExtensionArrayExtending pandas with custom dtypes or arrays.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions