__getitem__ for the case where the key is a slice object.
(self, key: slice)
| 4278 | |
| 4279 | @final |
| 4280 | def _getitem_slice(self, key: slice) -> Self: |
| 4281 | """ |
| 4282 | __getitem__ for the case where the key is a slice object. |
| 4283 | """ |
| 4284 | # _convert_slice_indexer to determine if this slice is positional |
| 4285 | # or label based, and if the latter, convert to positional |
| 4286 | slobj = self.index._convert_slice_indexer(key, kind="getitem") |
| 4287 | if isinstance(slobj, np.ndarray): |
| 4288 | # reachable with DatetimeIndex |
| 4289 | indexer = lib.maybe_indices_to_slice(slobj.astype(np.intp), len(self)) |
| 4290 | if isinstance(indexer, np.ndarray): |
| 4291 | # GH#43223 If we can not convert, use take |
| 4292 | return self.take(indexer, axis=0) |
| 4293 | slobj = indexer |
| 4294 | return self._slice(slobj) |
| 4295 | |
| 4296 | def _slice(self, slobj: slice, axis: AxisInt = 0) -> Self: |
| 4297 | """ |
no test coverage detected