diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 96090904b829f..4d2323b1910df 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1301,7 +1301,9 @@ def __add__(self, other): # as is_integer returns True for these if not is_period_dtype(self.dtype): raise integer_op_not_supported(self) - result = self._time_shift(other) + result = cast("PeriodArray", self)._addsub_int_array_or_scalar( + other * self.freq.n, operator.add + ) # array-like others elif is_timedelta64_dtype(other_dtype): @@ -1357,7 +1359,9 @@ def __sub__(self, other): # as is_integer returns True for these if not is_period_dtype(self.dtype): raise integer_op_not_supported(self) - result = self._time_shift(-other) + result = cast("PeriodArray", self)._addsub_int_array_or_scalar( + other * self.freq.n, operator.sub + ) elif isinstance(other, Period): result = self._sub_period(other) diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index fd5944fb63954..dd57bb9d121fd 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -549,10 +549,7 @@ def _time_shift(self, periods: int, freq=None) -> PeriodArray: "`freq` argument is not supported for " f"{type(self).__name__}._time_shift" ) - values = self.asi8 + periods * self.freq.n - if self._hasna: - values[self._isnan] = iNaT - return type(self)(values, freq=self.freq) + return self + periods def _box_func(self, x) -> Period | NaTType: return Period._from_ordinal(ordinal=x, freq=self.freq)