Skip to content

BUG: Series[td64].astype("string").astype("timedelta64[ns]") raises #38509

Closed
@jbrockmendel

Description

@jbrockmendel
tdi = pd.timedelta_range("1 Day", periods=3)

ser = pd.Series(tdi)

>>> ser.astype("string")
0    1 days
1    2 days
2    3 days
dtype: string

>>> ser.astype("string").astype(ser.dtype)
[...]
ValueError: Could not convert object to NumPy timedelta

We have a round-trip test for string -> dt64 in test_astype_roundtrip, should amend that to do td64 when this is fixed

Metadata

Metadata

Assignees

No one assigned

    Labels

    AstypeBugDtype ConversionsUnexpected or buggy dtype conversionsStringsString extension data type and string dataTimedeltaTimedelta data type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions