On a Series with a DatetimeIndex, what does shift(1, freq='D') do that shift(1) alone does not?
Correct answer
D. It shifts the index labels by a day, keeping values with their labels
14 views
D. It shifts the index labels by a day, keeping values with their labels
14 views
With a freq argument, shift moves the index itself rather than the data, so each value keeps its own label offset by the given period and no NaN rows appear. Without freq, only the values move down and the first row becomes NaN. This distinction matters when aligning two time series that were sampled with a known reporting lag.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is D? Ask here and get an explanation.