Skip to content

BUG: all-NaT TimedeltaArray division with object dtype array doesn't preserve dtype #39750

Closed
@jorisvandenbossche

Description

@jorisvandenbossche
In [27]: pd.array(["1 days", "2 days"], dtype="timedelta64[ns]") / np.array([2, 2])
Out[27]: 
<TimedeltaArray>
['0 days 12:00:00', '1 days 00:00:00']
Length: 2, dtype: timedelta64[ns]

In [28]: pd.array(["1 days", "2 days"], dtype="timedelta64[ns]") / np.array([2, 2], dtype=object)
Out[28]: 
<TimedeltaArray>
['0 days 12:00:00', '1 days 00:00:00']
Length: 2, dtype: timedelta64[ns]

In [29]: pd.array(["NaT", "NaT"], dtype="timedelta64[ns]") / np.array([2, 2])
Out[29]: 
<TimedeltaArray>
[NaT, NaT]
Length: 2, dtype: timedelta64[ns]

In [30]: pd.array(["NaT", "NaT"], dtype="timedelta64[ns]") / np.array([2, 2], dtype=object)
Out[30]: array([NaT, NaT], dtype=object)

The last case doesn't result in a TimedeltaArray as result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateNumeric OperationsArithmetic, Comparison, and Logical operationsTimedeltaTimedelta data type

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions