@@ -73,34 +73,30 @@ class DatetimeIndexOpsMixin(ExtensionOpsMixin):
73
73
DatetimeLikeArrayMixin ._maybe_mask_results )
74
74
__iter__ = ea_passthrough (DatetimeLikeArrayMixin .__iter__ )
75
75
76
- @property
77
- def _eadata (self ):
78
- return self ._data
79
-
80
76
@property
81
77
def freq (self ):
82
78
"""
83
79
Return the frequency object if it is set, otherwise None.
84
80
"""
85
- return self ._eadata .freq
81
+ return self ._data .freq
86
82
87
83
@freq .setter
88
84
def freq (self , value ):
89
- # validation is handled by _eadata setter
90
- self ._eadata .freq = value
85
+ # validation is handled by _data setter
86
+ self ._data .freq = value
91
87
92
88
@property
93
89
def freqstr (self ):
94
90
"""
95
91
Return the frequency object as a string if it is set, otherwise None.
96
92
"""
97
- return self ._eadata .freqstr
93
+ return self ._data .freqstr
98
94
99
95
def unique (self , level = None ):
100
96
if level is not None :
101
97
self ._validate_index_level (level )
102
98
103
- result = self ._eadata .unique ()
99
+ result = self ._data .unique ()
104
100
105
101
# Note: if `self` is already unique, then self.unique() should share
106
102
# a `freq` with self. If not already unique, then self.freq must be
@@ -113,7 +109,7 @@ def _create_comparison_method(cls, op):
113
109
Create a comparison method that dispatches to ``cls.values``.
114
110
"""
115
111
def wrapper (self , other ):
116
- result = op (self ._eadata , maybe_unwrap_index (other ))
112
+ result = op (self ._data , maybe_unwrap_index (other ))
117
113
return result
118
114
119
115
wrapper .__doc__ = op .__doc__
@@ -122,7 +118,7 @@ def wrapper(self, other):
122
118
123
119
@property
124
120
def _ndarray_values (self ):
125
- return self ._eadata ._ndarray_values
121
+ return self ._data ._ndarray_values
126
122
127
123
# ------------------------------------------------------------------------
128
124
# Abstract data attributes
@@ -131,12 +127,12 @@ def _ndarray_values(self):
131
127
def values (self ):
132
128
# type: () -> np.ndarray
133
129
# Note: PeriodArray overrides this to return an ndarray of objects.
134
- return self ._eadata ._data
130
+ return self ._data ._data
135
131
136
132
@property
137
133
@Appender (DatetimeLikeArrayMixin .asi8 .__doc__ )
138
134
def asi8 (self ):
139
- return self ._eadata .asi8
135
+ return self ._data .asi8
140
136
141
137
# ------------------------------------------------------------------------
142
138
@@ -485,7 +481,7 @@ def _add_datetimelike_methods(cls):
485
481
486
482
def __add__ (self , other ):
487
483
# dispatch to ExtensionArray implementation
488
- result = self ._eadata .__add__ (maybe_unwrap_index (other ))
484
+ result = self ._data .__add__ (maybe_unwrap_index (other ))
489
485
return wrap_arithmetic_op (self , other , result )
490
486
491
487
cls .__add__ = __add__
@@ -497,13 +493,13 @@ def __radd__(self, other):
497
493
498
494
def __sub__ (self , other ):
499
495
# dispatch to ExtensionArray implementation
500
- result = self ._eadata .__sub__ (maybe_unwrap_index (other ))
496
+ result = self ._data .__sub__ (maybe_unwrap_index (other ))
501
497
return wrap_arithmetic_op (self , other , result )
502
498
503
499
cls .__sub__ = __sub__
504
500
505
501
def __rsub__ (self , other ):
506
- result = self ._eadata .__rsub__ (maybe_unwrap_index (other ))
502
+ result = self ._data .__rsub__ (maybe_unwrap_index (other ))
507
503
return wrap_arithmetic_op (self , other , result )
508
504
509
505
cls .__rsub__ = __rsub__
@@ -534,7 +530,6 @@ def repeat(self, repeats, axis=None):
534
530
nv .validate_repeat (tuple (), dict (axis = axis ))
535
531
freq = self .freq if is_period_dtype (self ) else None
536
532
return self ._shallow_copy (self .asi8 .repeat (repeats ), freq = freq )
537
- # TODO: dispatch to _eadata
538
533
539
534
@Appender (_index_shared_docs ['where' ] % _index_doc_kwargs )
540
535
def where (self , cond , other = None ):
@@ -599,10 +594,10 @@ def astype(self, dtype, copy=True):
599
594
# Ensure that self.astype(self.dtype) is self
600
595
return self
601
596
602
- new_values = self ._eadata .astype (dtype , copy = copy )
597
+ new_values = self ._data .astype (dtype , copy = copy )
603
598
604
599
# pass copy=False because any copying will be done in the
605
- # _eadata .astype call above
600
+ # _data .astype call above
606
601
return Index (new_values ,
607
602
dtype = new_values .dtype , name = self .name , copy = False )
608
603
@@ -637,7 +632,7 @@ def shift(self, periods, freq=None):
637
632
Index.shift : Shift values of Index.
638
633
PeriodIndex.shift : Shift values of PeriodIndex.
639
634
"""
640
- result = self ._eadata ._time_shift (periods , freq = freq )
635
+ result = self ._data ._time_shift (periods , freq = freq )
641
636
return type (self )(result , name = self .name )
642
637
643
638
@@ -675,9 +670,6 @@ def maybe_unwrap_index(obj):
675
670
unwrapped object
676
671
"""
677
672
if isinstance (obj , ABCIndexClass ):
678
- if isinstance (obj , DatetimeIndexOpsMixin ):
679
- # i.e. PeriodIndex/DatetimeIndex/TimedeltaIndex
680
- return obj ._eadata
681
673
return obj ._data
682
674
return obj
683
675
@@ -712,16 +704,16 @@ def _delegate_class(self):
712
704
raise AbstractMethodError
713
705
714
706
def _delegate_property_get (self , name , * args , ** kwargs ):
715
- result = getattr (self ._eadata , name )
707
+ result = getattr (self ._data , name )
716
708
if name not in self ._raw_properties :
717
709
result = Index (result , name = self .name )
718
710
return result
719
711
720
712
def _delegate_property_set (self , name , value , * args , ** kwargs ):
721
- setattr (self ._eadata , name , value )
713
+ setattr (self ._data , name , value )
722
714
723
715
def _delegate_method (self , name , * args , ** kwargs ):
724
- result = operator .methodcaller (name , * args , ** kwargs )(self ._eadata )
716
+ result = operator .methodcaller (name , * args , ** kwargs )(self ._data )
725
717
if name not in self ._raw_methods :
726
718
result = Index (result , name = self .name )
727
719
return result
0 commit comments