30
30
is_object_dtype , is_timedelta64_dtype ,
31
31
is_datetime64_dtype , is_datetime64tz_dtype ,
32
32
is_bool_dtype , is_datetimetz ,
33
- is_list_like ,
33
+ is_list_like , is_offsetlike ,
34
34
is_scalar ,
35
35
_ensure_object )
36
36
from pandas .core .dtypes .cast import maybe_upcast_putmask , find_common_type
37
37
from pandas .core .dtypes .generic import (
38
38
ABCSeries ,
39
39
ABCDataFrame ,
40
40
ABCIndex ,
41
- ABCPeriodIndex ,
42
- ABCDateOffset )
41
+ ABCPeriodIndex )
43
42
44
43
# -----------------------------------------------------------------------------
45
44
# Functions that add arithmetic methods to objects, given arithmetic factory
@@ -363,7 +362,7 @@ def __init__(self, left, right, name, na_op):
363
362
rvalues = self ._convert_to_array (right , name = name , other = lvalues )
364
363
365
364
# left
366
- self .is_offset_lhs = self . _is_offset (left )
365
+ self .is_offset_lhs = is_offsetlike (left )
367
366
self .is_timedelta_lhs = is_timedelta64_dtype (lvalues )
368
367
self .is_datetime64_lhs = is_datetime64_dtype (lvalues )
369
368
self .is_datetime64tz_lhs = is_datetime64tz_dtype (lvalues )
@@ -373,7 +372,7 @@ def __init__(self, left, right, name, na_op):
373
372
self .is_floating_lhs = left .dtype .kind == 'f'
374
373
375
374
# right
376
- self .is_offset_rhs = self . _is_offset (right )
375
+ self .is_offset_rhs = is_offsetlike (right )
377
376
self .is_datetime64_rhs = is_datetime64_dtype (rvalues )
378
377
self .is_datetime64tz_rhs = is_datetime64tz_dtype (rvalues )
379
378
self .is_datetime_rhs = (self .is_datetime64_rhs or
@@ -515,7 +514,7 @@ def _convert_to_array(self, values, name=None, other=None):
515
514
values = np .empty (values .shape , dtype = other .dtype )
516
515
values [:] = iNaT
517
516
return values
518
- elif self . _is_offset (values ):
517
+ elif is_offsetlike (values ):
519
518
return values
520
519
else :
521
520
raise TypeError ("incompatible type [{dtype}] for a "
@@ -618,15 +617,6 @@ def f(x):
618
617
619
618
return lvalues , rvalues
620
619
621
- def _is_offset (self , arr_or_obj ):
622
- """ check if obj or all elements of list-like is DateOffset """
623
- if isinstance (arr_or_obj , ABCDateOffset ):
624
- return True
625
- elif (is_list_like (arr_or_obj ) and len (arr_or_obj ) and
626
- is_object_dtype (arr_or_obj )):
627
- return all (isinstance (x , ABCDateOffset ) for x in arr_or_obj )
628
- return False
629
-
630
620
631
621
def _align_method_SERIES (left , right , align_asobject = False ):
632
622
""" align lhs and rhs Series """
0 commit comments