Skip to content

BUG: DatetimeArray/Series incorrectly accepts timedelta64('NaT') for __setitem__ #27297

Closed
@jbrockmendel

Description

@jbrockmendel
dti = pd.date_range('2016-01-01', periods=3)
nat = np.timedelta64('NaT')

dta = dti._data.copy()
dta[0] = nat  # <-- should raise TypeError, doesn't

ser = pd.Series(dti.copy())
ser[1] = nat  # <-- should raise TypeError, doesn't

df = pd.DataFrame(dti.copy())
df.loc[2, 0] = nat  # <-- should raise TypeError, doesn't

I haven't checked, but I expect the same thing happens in reverse for Timedelta, possible Period dtypes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateTimedeltaTimedelta data type

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions