BUG: DatetimeArray/Series incorrectly accepts timedelta64('NaT') for setitem · Issue #27297 · pandas-dev/pandas (original) (raw)
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.