def _swaplevel_index(self, i: Union[(int, Name)], j: Union[(int, Name)]) -> InternalFrame:
    assert isinstance(self.index, ps.MultiIndex)
    for index in (i, j):
        if ((not isinstance(index, int)) and (index not in self.index.names)):
            raise KeyError(('Level %s not found' % index))
    i = (i if isinstance(i, int) else self.index.names.index(i))
    j = (j if isinstance(j, int) else self.index.names.index(j))
    for index in (i, j):
        if ((index >= self._internal.index_level) or (index < (- self._internal.index_level))):
            raise IndexError(('Too many levels: Index has only %s levels, %s is not a valid level number' % (self._internal.index_level, index)))
    index_map = list(zip(self._internal.index_spark_columns, self._internal.index_names, self._internal.index_fields))
    (index_map[i], index_map[j]) = (index_map[j], index_map[i])
    (index_spark_columns, index_names, index_fields) = zip(*index_map)
    internal = self._internal.copy(index_spark_columns=list(index_spark_columns), index_names=list(index_names), index_fields=list(index_fields))
    return internal
def _swaplevel_index(self, i: Union[(int, Name)], j: Union[(int, Name)]) -> InternalFrame:
    assert isinstance(self.index, ps.MultiIndex)
    for index in (i, j):
        if ((not isinstance(index, int)) and (index not in self.index.names)):
            raise KeyError(('Level %s not found' % index))
    i = (i if isinstance(i, int) else self.index.names.index(i))
    j = (j if isinstance(j, int) else self.index.names.index(j))
    for index in (i, j):
        if ((index >= self._internal.index_level) or (index < (- self._internal.index_level))):
            raise IndexError(('Too many levels: Index has only %s levels, %s is not a valid level number' % (self._internal.index_level, index)))
    index_map = list(zip(self._internal.index_spark_columns, self._internal.index_names, self._internal.index_fields))
    (index_map[i], index_map[j]) = (index_map[j], index_map[i])
    (index_spark_columns, index_names, index_fields) = zip(*index_map)
    internal = self._internal.copy(index_spark_columns=list(index_spark_columns), index_names=list(index_names), index_fields=list(index_fields))
    return internal