Analogue to get_indexer that raises if any elements are missing.
(self, key, axis_name: str_t)
| 6286 | return indexer |
| 6287 | |
| 6288 | def _get_indexer_strict(self, key, axis_name: str_t) -> tuple[Index, np.ndarray]: |
| 6289 | """ |
| 6290 | Analogue to get_indexer that raises if any elements are missing. |
| 6291 | """ |
| 6292 | keyarr = key |
| 6293 | if not isinstance(keyarr, Index): |
| 6294 | keyarr = com.asarray_tuplesafe(keyarr) |
| 6295 | |
| 6296 | if self._index_as_unique: |
| 6297 | indexer = self.get_indexer_for(keyarr) |
| 6298 | keyarr = self.reindex(keyarr)[0] |
| 6299 | else: |
| 6300 | keyarr, indexer, new_indexer = self._reindex_non_unique(keyarr) |
| 6301 | |
| 6302 | self._raise_if_missing(keyarr, indexer, axis_name) |
| 6303 | |
| 6304 | keyarr = self.take(indexer) |
| 6305 | if isinstance(key, Index): |
| 6306 | # GH 42790 - Preserve name from an Index |
| 6307 | keyarr.name = key.name |
| 6308 | if lib.is_np_dtype(keyarr.dtype, "mM") or isinstance( |
| 6309 | keyarr.dtype, DatetimeTZDtype |
| 6310 | ): |
| 6311 | # DTI/TDI.take can infer a freq in some cases when we dont want one |
| 6312 | if isinstance(key, list) or ( |
| 6313 | isinstance(key, type(self)) |
| 6314 | # "Index" has no attribute "freq" |
| 6315 | and key.freq is None # type: ignore[attr-defined] |
| 6316 | ): |
| 6317 | # error: "Index" has no attribute "_with_freq"; maybe "_with_infer"? |
| 6318 | keyarr = keyarr._with_freq(None) # type: ignore[attr-defined] |
| 6319 | |
| 6320 | return keyarr, indexer |
| 6321 | |
| 6322 | def _raise_if_missing(self, key, indexer, axis_name: str_t) -> None: |
| 6323 | """ |
no test coverage detected