'Sets the slices attribute to be a list of indices of the sorted
groups for the first index level. I.e., self.slices[0] is the
index where each observation is in the first (sorted) group.'

def get_slices(self, level=0):

    groups = self.index.get_level_values(level).unique()
    groups = np.array(groups)
    groups.sort()
    if isinstance(self.index, MultiIndex):
        self.slices = [self.index.get_loc_level(x, level=level)[0] for x in groups]
    else:
        self.slices = [self.index.get_loc(x) for x in groups]
