def _convert_to_indexer(self, obj, axis=None, is_setter=False,<EOL>raise_missing=False):
if axis is None:<EOL><INDENT>axis = self.axis or <NUM_LIT:0><EOL><DEDENT>labels = self.obj._get_axis(axis)<EOL>if isinstance(obj, slice):<EOL><INDENT>return self._convert_slice_indexer(obj, axis)<EOL><DEDENT>try:<EOL><INDENT>obj = self._convert_scalar_indexer(obj, axis)<EOL><DEDENT>except TypeError:<EOL><INDENT>if is_setter:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>is_int_index = labels.is_integer()<EOL>is_int_positional = is_integer(obj) and not is_int_index<EOL>try:<EOL><INDENT>return labels.get_loc(obj)<EOL><DEDENT>except LookupError:<EOL><INDENT>if isinstance(obj, tuple) and isinstance(labels, MultiIndex):<EOL><INDENT>if is_setter and len(obj) == labels.nlevels:<EOL><INDENT>return {'<STR_LIT:key>': obj}<EOL><DEDENT>raise<EOL><DEDENT><DEDENT>except TypeError:<EOL><INDENT>pass<EOL><DEDENT>except (ValueError):<EOL><INDENT>if not is_int_positional:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>if is_int_positional:<EOL><INDENT>if is_setter:<EOL><INDENT>if self.name == '<STR_LIT>':<EOL><INDENT>return {'<STR_LIT:key>': obj}<EOL><DEDENT>if (obj >= self.obj.shape[axis] and<EOL>not isinstance(labels, MultiIndex)):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>return obj<EOL><DEDENT>if is_nested_tuple(obj, labels):<EOL><INDENT>return labels.get_locs(obj)<EOL><DEDENT>elif is_list_like_indexer(obj):<EOL><INDENT>if com.is_bool_indexer(obj):<EOL><INDENT>obj = check_bool_indexer(labels, obj)<EOL>inds, = obj.nonzero()<EOL>return inds<EOL><DEDENT>else:<EOL><INDENT>kwargs = {'<STR_LIT>': True if is_setter else<EOL>raise_missing}<EOL>return self._get_listlike_indexer(obj, axis, **kwargs)[<NUM_LIT:1>]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>return labels.get_loc(obj)<EOL><DEDENT>except LookupError:<EOL><INDENT>if not is_list_like_indexer(obj) and is_setter:<EOL><INDENT>return {'<STR_LIT:key>': obj}<EOL><DEDENT>raise<EOL><DEDENT><DEDENT>
Convert indexing key into something we can use to do actual fancy
indexing on an ndarray

Examples
ix[:5] -> slice(0, 5)
ix[[1,2,3]] -> [1,2,3]
ix[['foo', 'bar', 'baz']] -> [i, j, k] (indices of foo, bar, baz)

Going by Zen of Python?
'In the face of ambiguity, refuse the temptation to guess.'
raise AmbiguousIndexError with integer labels?
- No, prefer label-based indexing