@@ -98,7 +98,7 @@ def f(self):
9898 return property (f )
9999
100100
101- def _dt_index_cmp (opname , nat_result = False ):
101+ def _dt_index_cmp (opname , cls , nat_result = False ):
102102 """
103103 Wrap comparison operations to convert datetime-like to datetime64
104104 """
@@ -135,7 +135,7 @@ def wrapper(self, other):
135135 return result
136136 return Index (result )
137137
138- return wrapper
138+ return compat . set_function_name ( wrapper , opname , cls )
139139
140140
141141def _ensure_datetime64 (other ):
@@ -277,12 +277,15 @@ def _join_i8_wrapper(joinf, **kwargs):
277277 libjoin .left_join_indexer_unique_int64 , with_indexers = False )
278278 _arrmap = None
279279
280- __eq__ = _dt_index_cmp ('__eq__' )
281- __ne__ = _dt_index_cmp ('__ne__' , nat_result = True )
282- __lt__ = _dt_index_cmp ('__lt__' )
283- __gt__ = _dt_index_cmp ('__gt__' )
284- __le__ = _dt_index_cmp ('__le__' )
285- __ge__ = _dt_index_cmp ('__ge__' )
280+ @classmethod
281+ def _add_comparison_methods (cls ):
282+ """ add in comparison methods """
283+ cls .__eq__ = _dt_index_cmp ('__eq__' , cls )
284+ cls .__ne__ = _dt_index_cmp ('__ne__' , cls , nat_result = True )
285+ cls .__lt__ = _dt_index_cmp ('__lt__' , cls )
286+ cls .__gt__ = _dt_index_cmp ('__gt__' , cls )
287+ cls .__le__ = _dt_index_cmp ('__le__' , cls )
288+ cls .__ge__ = _dt_index_cmp ('__ge__' , cls )
286289
287290 _engine_type = libindex .DatetimeEngine
288291
@@ -1599,14 +1602,15 @@ def slice_indexer(self, start=None, end=None, step=None, kind=None):
15991602 else :
16001603 raise
16011604
1602- # alias to offset
1603- def _get_freq (self ):
1605+ @property
1606+ def freq (self ):
1607+ """get/set the frequency of the Index"""
16041608 return self .offset
16051609
1606- def _set_freq (self , value ):
1610+ @freq .setter
1611+ def freq (self , value ):
1612+ """get/set the frequency of the Index"""
16071613 self .offset = value
1608- freq = property (fget = _get_freq , fset = _set_freq ,
1609- doc = "get/set the frequency of the Index" )
16101614
16111615 year = _field_accessor ('year' , 'Y' , "The year of the datetime" )
16121616 month = _field_accessor ('month' , 'M' ,
@@ -2014,6 +2018,7 @@ def to_julian_date(self):
20142018 ) / 24.0 )
20152019
20162020
2021+ DatetimeIndex ._add_comparison_methods ()
20172022DatetimeIndex ._add_numeric_methods_disabled ()
20182023DatetimeIndex ._add_logical_methods_disabled ()
20192024DatetimeIndex ._add_datetimelike_methods ()
0 commit comments