MCPcopy
hub / github.com/pandas-dev/pandas / _check_indexing_method

Method _check_indexing_method

pandas/core/indexes/base.py:3840–3883  ·  view source on GitHub ↗

Raise if we have a get_indexer `method` that is not supported or valid.

(
        self,
        method: str_t | None,
        limit: int | None = None,
        tolerance=None,
    )

Source from the content-addressed store, hash-verified

3838
3839 @final
3840 def _check_indexing_method(
3841 self,
3842 method: str_t | None,
3843 limit: int | None = None,
3844 tolerance=None,
3845 ) -> None:
3846 """
3847 Raise if we have a get_indexer `method` that is not supported or valid.
3848 """
3849 if method not in [None, "bfill", "backfill", "pad", "ffill", "nearest"]:
3850 # in practice the clean_reindex_fill_method call would raise
3851 # before we get here
3852 raise ValueError("Invalid fill method") # pragma: no cover
3853
3854 if self._is_multi:
3855 if method == "nearest":
3856 raise NotImplementedError(
3857 "method='nearest' not implemented yet "
3858 "for MultiIndex; see GitHub issue 9365"
3859 )
3860 if method in ("pad", "backfill"):
3861 if tolerance is not None:
3862 raise NotImplementedError(
3863 "tolerance not implemented yet for MultiIndex"
3864 )
3865
3866 if isinstance(self.dtype, (IntervalDtype, CategoricalDtype)):
3867 # GH#37871 for now this is only for IntervalIndex and CategoricalIndex
3868 if method is not None:
3869 raise NotImplementedError(
3870 f"method {method} not yet implemented for {type(self).__name__}"
3871 )
3872
3873 if method is None:
3874 if tolerance is not None:
3875 raise ValueError(
3876 "tolerance argument only valid if doing pad, "
3877 "backfill or nearest reindexing"
3878 )
3879 if limit is not None:
3880 raise ValueError(
3881 "limit argument only valid if doing pad, "
3882 "backfill or nearest reindexing"
3883 )
3884
3885 def _convert_tolerance(self, tolerance, target: np.ndarray | Index) -> np.ndarray:
3886 # override this method on subclasses

Callers 1

get_indexerMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected