code: def _get_index(self, dim, index):
      
      if isinstance(index, six.string_types):
        try:
          return self._index_names[dim][index]
        except KeyError:
          raise KeyError("Name '%s' is invalid for axis %s." % (index, dim))
        except TypeError:
          raise TypeError(
              "Trying to access an unnamed axis %s by name: '%s'" % (dim, index))
      else:
        return index
docs: Turn a string into a real index, otherwise return the index.