16
16
)
17
17
from pandas .core .dtypes .missing import is_valid_nat_for_dtype
18
18
19
- from pandas .core .accessor import delegate_names
20
19
from pandas .core .arrays import datetimelike as dtl
21
20
from pandas .core .arrays .timedeltas import TimedeltaArray
22
21
import pandas .core .common as com
28
27
)
29
28
from pandas .core .indexes .datetimelike import (
30
29
DatetimeIndexOpsMixin ,
31
- DatetimelikeDelegateMixin ,
32
30
DatetimeTimedeltaMixin ,
33
31
)
34
32
from pandas .core .indexes .extension import inherit_names
35
33
36
34
from pandas .tseries .frequencies import to_offset
37
35
38
36
39
- class TimedeltaDelegateMixin (DatetimelikeDelegateMixin ):
40
- # Most attrs are dispatched via datetimelike_{ops,methods}
41
- # Some are "raw" methods, the result is not re-boxed in an Index
42
- # We also have a few "extra" attrs, which may or may not be raw,
43
- # which we don't want to expose in the .dt accessor.
44
- _raw_properties = {"components" , "_box_func" }
45
- _raw_methods = {"to_pytimedelta" , "sum" , "std" , "median" , "_format_native_types" }
46
-
47
- _delegated_properties = TimedeltaArray ._datetimelike_ops + list (_raw_properties )
48
- _delegated_methods = TimedeltaArray ._datetimelike_methods + list (_raw_methods )
49
-
50
-
51
37
@inherit_names (
52
- ["_box_values" , "__neg__" , "__pos__" , "__abs__" ], TimedeltaArray , wrap = True
38
+ [
39
+ "_box_values" ,
40
+ "__neg__" ,
41
+ "__pos__" ,
42
+ "__abs__" ,
43
+ "total_seconds" ,
44
+ "round" ,
45
+ "floor" ,
46
+ "ceil" ,
47
+ ]
48
+ + TimedeltaArray ._field_ops ,
49
+ TimedeltaArray ,
50
+ wrap = True ,
53
51
)
54
52
@inherit_names (
55
53
[
@@ -59,21 +57,18 @@ class TimedeltaDelegateMixin(DatetimelikeDelegateMixin):
59
57
"_datetimelike_ops" ,
60
58
"_datetimelike_methods" ,
61
59
"_other_ops" ,
60
+ "components" ,
61
+ "_box_func" ,
62
+ "to_pytimedelta" ,
63
+ "sum" ,
64
+ "std" ,
65
+ "median" ,
66
+ "_format_native_types" ,
67
+ "freq" ,
62
68
],
63
69
TimedeltaArray ,
64
70
)
65
- @delegate_names (
66
- TimedeltaArray , TimedeltaDelegateMixin ._delegated_properties , typ = "property"
67
- )
68
- @delegate_names (
69
- TimedeltaArray ,
70
- TimedeltaDelegateMixin ._delegated_methods ,
71
- typ = "method" ,
72
- overwrite = True ,
73
- )
74
- class TimedeltaIndex (
75
- DatetimeTimedeltaMixin , dtl .TimelikeOps , TimedeltaDelegateMixin ,
76
- ):
71
+ class TimedeltaIndex (DatetimeTimedeltaMixin , dtl .TimelikeOps ):
77
72
"""
78
73
Immutable ndarray of timedelta64 data, represented internally as int64, and
79
74
which can be boxed to timedelta objects.
0 commit comments