

def get_loc(self, key, method=None, tolerance=None):
    "\n        Get integer location for requested label\n\n        Parameters\n        ----------\n        key : label\n        method : {None, 'pad'/'ffill', 'backfill'/'bfill', 'nearest'}, optional\n            * default: exact matches only.\n            * pad / ffill: find the PREVIOUS index value if no exact match.\n            * backfill / bfill: use NEXT index value if no exact match\n            * nearest: use the NEAREST index value if no exact match. Tied\n              distances are broken by preferring the larger index value.\n        tolerance : optional\n            Maximum distance from index value for inexact matches. The value of\n            the index at the matching location most satisfy the equation\n            ``abs(index[loc] - key) <= tolerance``.\n\n            .. versionadded:: 0.17.0\n\n        Returns\n        -------\n        loc : int if unique index, possibly slice or mask if not\n        "
    if (method is None):
        if (tolerance is not None):
            raise ValueError('tolerance argument only valid if using pad, backfill or nearest lookups')
        key = _values_from_object(key)
        try:
            return self._engine.get_loc(key)
        except KeyError:
            return self._engine.get_loc(self._maybe_cast_indexer(method))
    indexer = self.get_indexer([key], method=method, tolerance=tolerance)
    if ((indexer.ndim > 1) or (indexer.size > 1)):
        raise TypeError('get_loc requires scalar valued input')
    loc = indexer.item()
    if (loc == (- 1)):
        raise KeyError(key)
    return loc

dataset/ETHPy150Open pydata/pandas/pandas/indexes/base.py Index.get_loc/VarMisuse@86/451 `key`->`method`