BUG: DTA/TDA setitem breaks freq on views · Issue #31218 · pandas-dev/pandas (original) (raw)

@jbrockmendel

DatetimeArray/TimedeltaArray __setitem__ resets the array's freq to None, but this doesn't propagate to views:

dti = pd.date_range('2016-01-01', periods=5)
dta = dti._data
view = dta[:]
assert view.freq == dta.freq == "D"

dta[0] = pd.NaT
assert dta.freq is None

>>> view.freq
<Day>

view.freq is now incorrect.

It will be a hassle, but I think the thing to do is remove freq from DTA/TDA altogether. It has a different meaning from PeriodArray.freq and isn't necessary for the "vectorized Timestamp/Timedelta" abstraction.