// tuple list excluding level for grouping columns
if len(frame.columns.levels) > 2:
levs = []
for lev, level_codes in zip(this.columns.levels[:-1], this.columns.codes[:-1]):
if -1 in level_codes:
lev = np.append(lev, None)
levs.append(np.take(lev, level_codes))
tuples = list(zip(*levs))
unique_groups = [key for key, _ in itertools.groupby(tuples)]
new_names = this.columns.names[:-1]
new_columns = MultiIndex.from_tuples(unique_groups, names=new_names)
else: