30
30
from pandas ._libs import tslib , index as libindex
31
31
from pandas ._libs .tslibs .period import (Period , IncompatibleFrequency ,
32
32
get_period_field_arr ,
33
+ DIFFERENT_FREQ_INDEX ,
33
34
_validate_end_alias , _quarter_to_myear )
34
35
from pandas ._libs .tslibs .fields import isleapyear_arr
35
36
from pandas ._libs .tslibs import resolution , period
@@ -71,9 +72,6 @@ def dt64arr_to_periodarr(data, freq, tz):
71
72
# --- Period index sketch
72
73
73
74
74
- _DIFFERENT_FREQ_INDEX = period ._DIFFERENT_FREQ_INDEX
75
-
76
-
77
75
def _period_index_cmp (opname , cls ):
78
76
"""
79
77
Wrap comparison operations to convert Period-like to PeriodDtype
@@ -84,13 +82,13 @@ def wrapper(self, other):
84
82
op = getattr (self ._ndarray_values , opname )
85
83
if isinstance (other , Period ):
86
84
if other .freq != self .freq :
87
- msg = _DIFFERENT_FREQ_INDEX .format (self .freqstr , other .freqstr )
85
+ msg = DIFFERENT_FREQ_INDEX .format (self .freqstr , other .freqstr )
88
86
raise IncompatibleFrequency (msg )
89
87
90
88
result = op (other .ordinal )
91
89
elif isinstance (other , PeriodIndex ):
92
90
if other .freq != self .freq :
93
- msg = _DIFFERENT_FREQ_INDEX .format (self .freqstr , other .freqstr )
91
+ msg = DIFFERENT_FREQ_INDEX .format (self .freqstr , other .freqstr )
94
92
raise IncompatibleFrequency (msg )
95
93
96
94
result = op (other ._ndarray_values )
@@ -523,7 +521,7 @@ def astype(self, dtype, copy=True, how='start'):
523
521
def searchsorted (self , value , side = 'left' , sorter = None ):
524
522
if isinstance (value , Period ):
525
523
if value .freq != self .freq :
526
- msg = _DIFFERENT_FREQ_INDEX .format (self .freqstr , value .freqstr )
524
+ msg = DIFFERENT_FREQ_INDEX .format (self .freqstr , value .freqstr )
527
525
raise IncompatibleFrequency (msg )
528
526
value = value .ordinal
529
527
elif isinstance (value , compat .string_types ):
@@ -706,7 +704,7 @@ def _maybe_convert_timedelta(self, other):
706
704
base = frequencies .get_base_alias (freqstr )
707
705
if base == self .freq .rule_code :
708
706
return other .n
709
- msg = _DIFFERENT_FREQ_INDEX .format (self .freqstr , other .freqstr )
707
+ msg = DIFFERENT_FREQ_INDEX .format (self .freqstr , other .freqstr )
710
708
raise IncompatibleFrequency (msg )
711
709
elif is_integer (other ):
712
710
# integer is passed to .shift via
@@ -721,7 +719,7 @@ def _add_offset(self, other):
721
719
assert not isinstance (other , Tick )
722
720
base = frequencies .get_base_alias (other .rule_code )
723
721
if base != self .freq .rule_code :
724
- msg = _DIFFERENT_FREQ_INDEX .format (self .freqstr , other .freqstr )
722
+ msg = DIFFERENT_FREQ_INDEX .format (self .freqstr , other .freqstr )
725
723
raise IncompatibleFrequency (msg )
726
724
return self .shift (other .n )
727
725
@@ -753,7 +751,7 @@ def _sub_period(self, other):
753
751
# If the operation is well-defined, we return an object-Index
754
752
# of DateOffsets. Null entries are filled with pd.NaT
755
753
if self .freq != other .freq :
756
- msg = _DIFFERENT_FREQ_INDEX .format (self .freqstr , other .freqstr )
754
+ msg = DIFFERENT_FREQ_INDEX .format (self .freqstr , other .freqstr )
757
755
raise IncompatibleFrequency (msg )
758
756
759
757
asi8 = self .asi8
@@ -837,7 +835,7 @@ def get_indexer(self, target, method=None, limit=None, tolerance=None):
837
835
target = _ensure_index (target )
838
836
839
837
if hasattr (target , 'freq' ) and target .freq != self .freq :
840
- msg = _DIFFERENT_FREQ_INDEX .format (self .freqstr , target .freqstr )
838
+ msg = DIFFERENT_FREQ_INDEX .format (self .freqstr , target .freqstr )
841
839
raise IncompatibleFrequency (msg )
842
840
843
841
if isinstance (target , PeriodIndex ):
@@ -1010,7 +1008,7 @@ def _assert_can_do_setop(self, other):
1010
1008
raise ValueError ('can only call with other PeriodIndex-ed objects' )
1011
1009
1012
1010
if self .freq != other .freq :
1013
- msg = _DIFFERENT_FREQ_INDEX .format (self .freqstr , other .freqstr )
1011
+ msg = DIFFERENT_FREQ_INDEX .format (self .freqstr , other .freqstr )
1014
1012
raise IncompatibleFrequency (msg )
1015
1013
1016
1014
def _wrap_union_result (self , other , result ):
0 commit comments