code: def _index_dispatch(arg, df, axis):  # noqa: F811
      """Base function for selection on a Pandas Index object.
  
      Applies only to strings.
      It is also applicable to shell-like glob strings,
      which are supported by `fnmatch`.
  
      Returns either a sequence of booleans, an integer,
      or a slice.
      """
      index = getattr(df, axis)
      if isinstance(index, pd.MultiIndex):
          index = index.get_level_values(0)
      if _is_str_or_cat(index) or is_datetime64_dtype(index):
          try:
              return index.get_loc(arg)
          except KeyError as exc:
              if _is_str_or_cat(index):
                  if arg == "*":
                      return slice(None)
                  # label selection should be case sensitive
                  # fix for Github Issue 1160
                  # translating to regex solves the case sensitivity
                  # and also avoids the list comprehension
                  # not that list comprehension is bad - i'd say it is efficient
                  # however, the Pandas str.match method used in _select_regex
                  # could offer more performance, especially if the
                  # underlying array of the index is a PyArrow string array
                  return _select_regex(
                      index,
                      (arg, fnmatch.translate(arg)),
                      source="fnmatch",
                  )
              raise KeyError(
                  f"No match was returned for '{arg}'"
              ) from exc
      raise KeyError(f"No match was returned for '{arg}'")
  
imports: from __future__ import annotations
  import fnmatch
  import inspect
  import re
  import warnings
  from collections.abc import Callable
  from dataclasses import dataclass
  from enum import Enum
  from functools import singledispatch
  from typing import Any, Callable, Hashable, Iterable, List, Literal, Optional, Pattern, Union
  import numpy
  import pandas
  from multipledispatch import dispatch
  from pandas.api.types import is_bool_dtype, is_datetime64_dtype, is_list_like, is_scalar, is_string_dtype, union_categoricals
  from pandas.core.common import is_bool_indexer
  from pandas.core.groupby.generic import DataFrameGroupBy, SeriesGroupBy
  from janitor.utils import _expand_grid, check, check_column, find_stack_level
label_desc: Use image node_id 10 for calling a global function with example usage: _index_dispatch(arg, df, axis) and returns: index, _select_regex, slice