|
26 | 26 | cache_readonly,
|
27 | 27 | doc,
|
28 | 28 | )
|
29 |
| -from pandas.util._exceptions import rewrite_exception |
30 | 29 |
|
31 | 30 | from pandas.core.dtypes.common import (
|
32 | 31 | ensure_platform_int,
|
@@ -189,17 +188,6 @@ def _data(self) -> np.ndarray:
|
189 | 188 | """
|
190 | 189 | return np.arange(self.start, self.stop, self.step, dtype=np.int64)
|
191 | 190 |
|
192 |
| - @cache_readonly |
193 |
| - def _cached_int64index(self) -> Int64Index: |
194 |
| - return Int64Index._simple_new(self._data, name=self.name) |
195 |
| - |
196 |
| - @property |
197 |
| - def _int64index(self) -> Int64Index: |
198 |
| - # wrap _cached_int64index so we can be sure its name matches self.name |
199 |
| - res = self._cached_int64index |
200 |
| - res._name = self._name |
201 |
| - return res |
202 |
| - |
203 | 191 | def _get_data_as_items(self):
|
204 | 192 | """return a list of tuples of start, stop, step"""
|
205 | 193 | rng = self._range
|
@@ -425,24 +413,6 @@ def _get_indexer(
|
425 | 413 |
|
426 | 414 | # --------------------------------------------------------------------
|
427 | 415 |
|
428 |
| - def repeat(self, repeats, axis=None) -> Int64Index: |
429 |
| - return self._int64index.repeat(repeats, axis=axis) |
430 |
| - |
431 |
| - def delete(self, loc) -> Int64Index: # type: ignore[override] |
432 |
| - return self._int64index.delete(loc) |
433 |
| - |
434 |
| - def take( |
435 |
| - self, indices, axis: int = 0, allow_fill: bool = True, fill_value=None, **kwargs |
436 |
| - ) -> Int64Index: |
437 |
| - with rewrite_exception("Int64Index", type(self).__name__): |
438 |
| - return self._int64index.take( |
439 |
| - indices, |
440 |
| - axis=axis, |
441 |
| - allow_fill=allow_fill, |
442 |
| - fill_value=fill_value, |
443 |
| - **kwargs, |
444 |
| - ) |
445 |
| - |
446 | 416 | def tolist(self) -> list[int]:
|
447 | 417 | return list(self._range)
|
448 | 418 |
|
@@ -683,7 +653,8 @@ def _union(self, other: Index, sort):
|
683 | 653 | and (end_s - step_o <= end_o)
|
684 | 654 | ):
|
685 | 655 | return type(self)(start_r, end_r + step_o, step_o)
|
686 |
| - return self._int64index._union(other, sort=sort) |
| 656 | + |
| 657 | + return super()._union(other, sort=sort) |
687 | 658 |
|
688 | 659 | def _difference(self, other, sort=None):
|
689 | 660 | # optimized set operation if we have another RangeIndex
|
@@ -857,7 +828,8 @@ def __floordiv__(self, other):
|
857 | 828 | start = self.start // other
|
858 | 829 | new_range = range(start, start + 1, 1)
|
859 | 830 | return self._simple_new(new_range, name=self.name)
|
860 |
| - return self._int64index // other |
| 831 | + |
| 832 | + return super().__floordiv__(other) |
861 | 833 |
|
862 | 834 | # --------------------------------------------------------------------
|
863 | 835 | # Reductions
|
@@ -891,21 +863,22 @@ def _arith_method(self, other, op):
|
891 | 863 | elif isinstance(other, (timedelta, np.timedelta64)):
|
892 | 864 | # GH#19333 is_integer evaluated True on timedelta64,
|
893 | 865 | # so we need to catch these explicitly
|
894 |
| - return op(self._int64index, other) |
| 866 | + return super()._arith_method(other, op) |
895 | 867 | elif is_timedelta64_dtype(other):
|
896 | 868 | # Must be an np.ndarray; GH#22390
|
897 |
| - return op(self._int64index, other) |
| 869 | + return super()._arith_method(other, op) |
898 | 870 |
|
899 | 871 | if op in [
|
900 | 872 | operator.pow,
|
901 | 873 | ops.rpow,
|
902 | 874 | operator.mod,
|
903 | 875 | ops.rmod,
|
| 876 | + operator.floordiv, |
904 | 877 | ops.rfloordiv,
|
905 | 878 | divmod,
|
906 | 879 | ops.rdivmod,
|
907 | 880 | ]:
|
908 |
| - return op(self._int64index, other) |
| 881 | + return super()._arith_method(other, op) |
909 | 882 |
|
910 | 883 | step: Callable | None = None
|
911 | 884 | if op in [operator.mul, ops.rmul, operator.truediv, ops.rtruediv]:
|
@@ -946,5 +919,5 @@ def _arith_method(self, other, op):
|
946 | 919 |
|
947 | 920 | except (ValueError, TypeError, ZeroDivisionError):
|
948 | 921 | # Defer to Int64Index implementation
|
949 |
| - return op(self._int64index, other) |
950 |
| - # TODO: Do attrs get handled reliably? |
| 922 | + # test_arithmetic_explicit_conversions |
| 923 | + return super()._arith_method(other, op) |
0 commit comments