| 1482 | # error: Return type "Index" of "take" incompatible with return type |
| 1483 | # "RangeIndex" in supertype "Index" |
| 1484 | def take( # type: ignore[override] |
| 1485 | self, |
| 1486 | indices, |
| 1487 | axis: Axis = 0, |
| 1488 | allow_fill: bool = True, |
| 1489 | fill_value=None, |
| 1490 | **kwargs, |
| 1491 | ) -> Self | Index: |
| 1492 | if kwargs: |
| 1493 | nv.validate_take((), kwargs) |
| 1494 | if is_scalar(indices): |
| 1495 | raise TypeError("Expected indices to be array-like") |
| 1496 | indices = ensure_platform_int(indices) |
| 1497 | |
| 1498 | # raise an exception if allow_fill is True and fill_value is not None |
| 1499 | self._maybe_disallow_fill(allow_fill, fill_value, indices) |
| 1500 | |
| 1501 | if len(indices) == 0: |
| 1502 | return type(self)(_empty_range, name=self.name) |
| 1503 | else: |
| 1504 | ind_max = indices.max() |
| 1505 | if ind_max >= len(self): |
| 1506 | raise IndexError( |
| 1507 | f"index {ind_max} is out of bounds for axis 0 with size {len(self)}" |
| 1508 | ) |
| 1509 | ind_min = indices.min() |
| 1510 | if ind_min < -len(self): |
| 1511 | raise IndexError( |
| 1512 | f"index {ind_min} is out of bounds for axis 0 with size {len(self)}" |
| 1513 | ) |
| 1514 | taken = indices.astype(self.dtype, casting="safe") |
| 1515 | if ind_min < 0: |
| 1516 | taken %= len(self) |
| 1517 | if self.step != 1: |
| 1518 | taken *= self.step |
| 1519 | if self.start != 0: |
| 1520 | taken += self.start |
| 1521 | |
| 1522 | return self._shallow_copy(taken, name=self.name) |
| 1523 | |
| 1524 | def value_counts( |
| 1525 | self, |