def _time_shift(self, periods, freq=None):
if freq is not None:<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>.format(cls=type(self).__name__))<EOL><DEDENT>values = self.asi8 + periods * self.freq.n<EOL>if self._hasnans:<EOL><INDENT>values[self._isnan] = iNaT<EOL><DEDENT>return type(self)(values, freq=self.freq)<EOL>
Shift each value by `periods`.

Note this is different from ExtensionArray.shift, which
shifts the *position* of each element, padding the end with
missing values.

Parameters
----------
periods : int
    Number of periods to shift by.
freq : pandas.DateOffset, pandas.Timedelta, or string
    Frequency increment to shift by.