@@ -189,7 +189,7 @@ class DatetimeLikeArrayMixin(OpsMixin, NDArrayBackedExtensionArray):
189
189
Shared Base/Mixin class for DatetimeArray, TimedeltaArray, PeriodArray
190
190
191
191
Assumes that __new__/__init__ defines:
192
- _data
192
+ _ndarray
193
193
_freq
194
194
195
195
and that the inheriting class has methods:
@@ -1418,9 +1418,8 @@ def __add__(self, other):
1418
1418
# as is_integer returns True for these
1419
1419
if not is_period_dtype (self .dtype ):
1420
1420
raise integer_op_not_supported (self )
1421
- result = cast ("PeriodArray" , self )._addsub_int_array_or_scalar (
1422
- other * self .freq .n , operator .add
1423
- )
1421
+ obj = cast ("PeriodArray" , self )
1422
+ result = obj ._addsub_int_array_or_scalar (other * obj .freq .n , operator .add )
1424
1423
1425
1424
# array-like others
1426
1425
elif is_timedelta64_dtype (other_dtype ):
@@ -1435,9 +1434,8 @@ def __add__(self, other):
1435
1434
elif is_integer_dtype (other_dtype ):
1436
1435
if not is_period_dtype (self .dtype ):
1437
1436
raise integer_op_not_supported (self )
1438
- result = cast ("PeriodArray" , self )._addsub_int_array_or_scalar (
1439
- other * self .freq .n , operator .add
1440
- )
1437
+ obj = cast ("PeriodArray" , self )
1438
+ result = obj ._addsub_int_array_or_scalar (other * obj .freq .n , operator .add )
1441
1439
else :
1442
1440
# Includes Categorical, other ExtensionArrays
1443
1441
# For PeriodDtype, if self is a TimedeltaArray and other is a
@@ -1477,9 +1475,8 @@ def __sub__(self, other):
1477
1475
# as is_integer returns True for these
1478
1476
if not is_period_dtype (self .dtype ):
1479
1477
raise integer_op_not_supported (self )
1480
- result = cast ("PeriodArray" , self )._addsub_int_array_or_scalar (
1481
- other * self .freq .n , operator .sub
1482
- )
1478
+ obj = cast ("PeriodArray" , self )
1479
+ result = obj ._addsub_int_array_or_scalar (other * obj .freq .n , operator .sub )
1483
1480
1484
1481
elif isinstance (other , Period ):
1485
1482
result = self ._sub_periodlike (other )
@@ -1500,9 +1497,8 @@ def __sub__(self, other):
1500
1497
elif is_integer_dtype (other_dtype ):
1501
1498
if not is_period_dtype (self .dtype ):
1502
1499
raise integer_op_not_supported (self )
1503
- result = cast ("PeriodArray" , self )._addsub_int_array_or_scalar (
1504
- other * self .freq .n , operator .sub
1505
- )
1500
+ obj = cast ("PeriodArray" , self )
1501
+ result = obj ._addsub_int_array_or_scalar (other * obj .freq .n , operator .sub )
1506
1502
else :
1507
1503
# Includes ExtensionArrays, float_dtype
1508
1504
return NotImplemented
0 commit comments