|
24 | 24 | pandas_dtype,
|
25 | 25 | )
|
26 | 26 |
|
27 |
| -from pandas.core.accessor import delegate_names |
28 | 27 | from pandas.core.arrays.period import (
|
29 | 28 | PeriodArray,
|
30 | 29 | period_array,
|
|
39 | 38 | ensure_index,
|
40 | 39 | maybe_extract_name,
|
41 | 40 | )
|
42 |
| -from pandas.core.indexes.datetimelike import ( |
43 |
| - DatetimeIndexOpsMixin, |
44 |
| - DatetimelikeDelegateMixin, |
45 |
| -) |
| 41 | +from pandas.core.indexes.datetimelike import DatetimeIndexOpsMixin |
46 | 42 | from pandas.core.indexes.datetimes import DatetimeIndex, Index
|
| 43 | +from pandas.core.indexes.extension import inherit_names |
47 | 44 | from pandas.core.indexes.numeric import Int64Index
|
48 | 45 | from pandas.core.ops import get_op_result_name
|
49 | 46 | from pandas.core.tools.datetimes import DateParseError
|
@@ -71,23 +68,14 @@ def _new_PeriodIndex(cls, **d):
|
71 | 68 | return cls(values, **d)
|
72 | 69 |
|
73 | 70 |
|
74 |
| -class PeriodDelegateMixin(DatetimelikeDelegateMixin): |
75 |
| - """ |
76 |
| - Delegate from PeriodIndex to PeriodArray. |
77 |
| - """ |
78 |
| - |
79 |
| - _raw_methods = {"_format_native_types"} |
80 |
| - _raw_properties = {"is_leap_year", "freq"} |
81 |
| - |
82 |
| - _delegated_properties = PeriodArray._datetimelike_ops + list(_raw_properties) |
83 |
| - _delegated_methods = set(PeriodArray._datetimelike_methods) | _raw_methods |
84 |
| - |
85 |
| - |
86 |
| -@delegate_names(PeriodArray, PeriodDelegateMixin._delegated_properties, typ="property") |
87 |
| -@delegate_names( |
88 |
| - PeriodArray, PeriodDelegateMixin._delegated_methods, typ="method", overwrite=True |
| 71 | +@inherit_names( |
| 72 | + ["strftime", "to_timestamp", "asfreq", "start_time", "end_time"] |
| 73 | + + PeriodArray._field_ops, |
| 74 | + PeriodArray, |
| 75 | + wrap=True, |
89 | 76 | )
|
90 |
| -class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): |
| 77 | +@inherit_names(["is_leap_year", "freq", "_format_native_types"], PeriodArray) |
| 78 | +class PeriodIndex(DatetimeIndexOpsMixin, Int64Index): |
91 | 79 | """
|
92 | 80 | Immutable ndarray holding ordinal values indicating regular periods in time.
|
93 | 81 |
|
|
0 commit comments