'index : index-like
Can be pandas MultiIndex or Index or array-like. If array-like
and is a MultipleIndex (more than one grouping variable),
groups are expected to be in each row. E.g., [(\'red\', 1),
(\'red\', 2), (\'green\', 1), (\'green\', 2)]
names : list or str, optional
The names to use for the groups. Should be a str if only
one grouping variable is used.
Notes
If index is already a pandas Index then there is no copy.'

def __init__(self, index, names=None):

    if isinstance(index, (Index, MultiIndex)):
        if (names is not None):
            if hasattr(index, 'set_names'):
                index.set_names(names, inplace=True)
            else:
                index.names = names
        self.index = index
    else:
        if _is_hierarchical(index):
            self.index = _make_hierarchical_index(index, names)
        else:
            self.index = Index(index, name=names)
        if (names is None):
            names = _make_generic_names(self.index)
            if hasattr(self.index, 'set_names'):
                self.index.set_names(names, inplace=True)
            else:
                self.index.names = names
    self.nobs = len(self.index)
    self.nlevels = len(self.index.names)
    self.slices = None
