|
81 | 81 |
|
82 | 82 | from pandas import (
|
83 | 83 | Categorical,
|
| 84 | + CategoricalIndex, |
| 85 | + DatetimeIndex, |
84 | 86 | Index,
|
| 87 | + IntervalIndex, |
| 88 | + PeriodIndex, |
85 | 89 | )
|
86 | 90 | from pandas.core.arrays import (
|
87 | 91 | BaseMaskedArray,
|
@@ -671,6 +675,12 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None:
|
671 | 675 |
|
672 | 676 | return find_common_type(non_cat_dtypes)
|
673 | 677 |
|
| 678 | + @cache_readonly |
| 679 | + def index_class(self) -> type_t[CategoricalIndex]: |
| 680 | + from pandas import CategoricalIndex |
| 681 | + |
| 682 | + return CategoricalIndex |
| 683 | + |
674 | 684 |
|
675 | 685 | @register_extension_dtype
|
676 | 686 | class DatetimeTZDtype(PandasExtensionDtype):
|
@@ -911,6 +921,12 @@ def __setstate__(self, state) -> None:
|
911 | 921 | self._tz = state["tz"]
|
912 | 922 | self._unit = state["unit"]
|
913 | 923 |
|
| 924 | + @cache_readonly |
| 925 | + def index_class(self) -> type_t[DatetimeIndex]: |
| 926 | + from pandas import DatetimeIndex |
| 927 | + |
| 928 | + return DatetimeIndex |
| 929 | + |
914 | 930 |
|
915 | 931 | @register_extension_dtype
|
916 | 932 | class PeriodDtype(PeriodDtypeBase, PandasExtensionDtype):
|
@@ -1121,6 +1137,12 @@ def __from_arrow__(self, array: pa.Array | pa.ChunkedArray) -> PeriodArray:
|
1121 | 1137 | return PeriodArray(np.array([], dtype="int64"), dtype=self, copy=False)
|
1122 | 1138 | return PeriodArray._concat_same_type(results)
|
1123 | 1139 |
|
| 1140 | + @cache_readonly |
| 1141 | + def index_class(self) -> type_t[PeriodIndex]: |
| 1142 | + from pandas import PeriodIndex |
| 1143 | + |
| 1144 | + return PeriodIndex |
| 1145 | + |
1124 | 1146 |
|
1125 | 1147 | @register_extension_dtype
|
1126 | 1148 | class IntervalDtype(PandasExtensionDtype):
|
@@ -1384,6 +1406,12 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None:
|
1384 | 1406 | return np.dtype(object)
|
1385 | 1407 | return IntervalDtype(common, closed=closed)
|
1386 | 1408 |
|
| 1409 | + @cache_readonly |
| 1410 | + def index_class(self) -> type_t[IntervalIndex]: |
| 1411 | + from pandas import IntervalIndex |
| 1412 | + |
| 1413 | + return IntervalIndex |
| 1414 | + |
1387 | 1415 |
|
1388 | 1416 | class NumpyEADtype(ExtensionDtype):
|
1389 | 1417 | """
|
|
0 commit comments