1616)
1717from pandas .core .dtypes .missing import is_valid_nat_for_dtype
1818
19- from pandas .core .accessor import delegate_names
2019from pandas .core .arrays import datetimelike as dtl
2120from pandas .core .arrays .timedeltas import TimedeltaArray
2221import pandas .core .common as com
2827)
2928from pandas .core .indexes .datetimelike import (
3029 DatetimeIndexOpsMixin ,
31- DatetimelikeDelegateMixin ,
3230 DatetimeTimedeltaMixin ,
3331)
3432from pandas .core .indexes .extension import inherit_names
3533
3634from pandas .tseries .frequencies import to_offset
3735
3836
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-
5137@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 ,
5351)
5452@inherit_names (
5553 [
@@ -59,21 +57,18 @@ class TimedeltaDelegateMixin(DatetimelikeDelegateMixin):
5957 "_datetimelike_ops" ,
6058 "_datetimelike_methods" ,
6159 "_other_ops" ,
60+ "components" ,
61+ "_box_func" ,
62+ "to_pytimedelta" ,
63+ "sum" ,
64+ "std" ,
65+ "median" ,
66+ "_format_native_types" ,
67+ "freq" ,
6268 ],
6369 TimedeltaArray ,
6470)
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 ):
7772 """
7873 Immutable ndarray of timedelta64 data, represented internally as int64, and
7974 which can be boxed to timedelta objects.
0 commit comments