def merge_rows(self, key, merge_scalars=True):
        import utool as ut
        unique_labels, groupxs = self.group_indicies(key)
        single_xs = [xs for xs in groupxs if len(xs) == 1]
        multi_xs = [xs for xs in groupxs if len(xs) > 1]
        singles = self.take(ut.flatten(single_xs))
        multis = [self.take(idxs) for idxs in multi_xs]
        merged_groups = []
        for group in multis:
            newgroup = {}
            for key_ in group.keys():
                val = group[key_]
                if key_ == key:
                    val_ = val[0]
                elif hasattr(val[0].__class__, 'union'):
                    val_ = ut.oset.union(*val)
                elif isinstance(val[0], (ut.oset,)):
                    val_ = ut.oset.union(*val)
                elif isinstance(val[0], (set)):
                    val_ = set.union(*val)
                elif isinstance(val[0], (tuple, list)):
                    val_ = ut.flatten(val)
                else:
                    if ut.allsame(val):
                        val_ = val[0]
                    else:
                        if merge_scalars:
                            val_ = val
                        else:
                            if True:
                                other_vals = ut.filter_Nones(val)
                                if len(other_vals) == 1:
                                    val_ = val[0]
                                else:
                                    raise ValueError(
                                        'tried to merge a scalar in %r, val=%r' % (
                                            key_, val))
                            else:
                                raise ValueError(
                                    'tried to merge a scalar in %r, val=%r' % (
                                        key_, val))
                newgroup[key_] = [val_]
            merged_groups.append(ut.ColumnLists(newgroup))
        merged_multi = self.__class__.flatten(merged_groups)
        merged = singles + merged_multi
        return merged