@@ -98,7 +98,7 @@ def f(self):
98
98
return property (f )
99
99
100
100
101
- def _dt_index_cmp (opname , nat_result = False ):
101
+ def _dt_index_cmp (opname , cls , nat_result = False ):
102
102
"""
103
103
Wrap comparison operations to convert datetime-like to datetime64
104
104
"""
@@ -135,7 +135,7 @@ def wrapper(self, other):
135
135
return result
136
136
return Index (result )
137
137
138
- return wrapper
138
+ return compat . set_function_name ( wrapper , opname , cls )
139
139
140
140
141
141
def _ensure_datetime64 (other ):
@@ -277,12 +277,15 @@ def _join_i8_wrapper(joinf, **kwargs):
277
277
libjoin .left_join_indexer_unique_int64 , with_indexers = False )
278
278
_arrmap = None
279
279
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 )
286
289
287
290
_engine_type = libindex .DatetimeEngine
288
291
@@ -1599,14 +1602,15 @@ def slice_indexer(self, start=None, end=None, step=None, kind=None):
1599
1602
else :
1600
1603
raise
1601
1604
1602
- # alias to offset
1603
- def _get_freq (self ):
1605
+ @property
1606
+ def freq (self ):
1607
+ """get/set the frequency of the Index"""
1604
1608
return self .offset
1605
1609
1606
- def _set_freq (self , value ):
1610
+ @freq .setter
1611
+ def freq (self , value ):
1612
+ """get/set the frequency of the Index"""
1607
1613
self .offset = value
1608
- freq = property (fget = _get_freq , fset = _set_freq ,
1609
- doc = "get/set the frequency of the Index" )
1610
1614
1611
1615
year = _field_accessor ('year' , 'Y' , "The year of the datetime" )
1612
1616
month = _field_accessor ('month' , 'M' ,
@@ -2014,6 +2018,7 @@ def to_julian_date(self):
2014
2018
) / 24.0 )
2015
2019
2016
2020
2021
+ DatetimeIndex ._add_comparison_methods ()
2017
2022
DatetimeIndex ._add_numeric_methods_disabled ()
2018
2023
DatetimeIndex ._add_logical_methods_disabled ()
2019
2024
DatetimeIndex ._add_datetimelike_methods ()
0 commit comments