def _get_nearest_indexer(self, target, limit, tolerance):
left_indexer = self.get_indexer(target, '<STR_LIT>', limit=limit)<EOL>right_indexer = self.get_indexer(target, '<STR_LIT>', limit=limit)<EOL>target = np.asarray(target)<EOL>left_distances = abs(self.values[left_indexer] - target)<EOL>right_distances = abs(self.values[right_indexer] - target)<EOL>op = operator.lt if self.is_monotonic_increasing else operator.le<EOL>indexer = np.where(op(left_distances, right_distances) |<EOL>(right_indexer == -<NUM_LIT:1>), left_indexer, right_indexer)<EOL>if tolerance is not None:<EOL><INDENT>indexer = self._filter_indexer_tolerance(target, indexer,<EOL>tolerance)<EOL><DEDENT>return indexer<EOL>
Get the indexer for the nearest index labels; requires an index with
values that can be subtracted from each other (e.g., not strings or
tuples).