code: def result_subsets(self, rs):
          
          keyset, maxwid = set(), {}
          for r in rs:
              key = tuple(sorted(r.keys()))
              keyset.add(key)
              if key not in maxwid:
                  maxwid[key] = [len(k) for k in key]
              for i, k in enumerate(key):
                  strlen = len("{}".format(r[k]))
                  maxwid[key][i] = max(maxwid[key][i], strlen)
          return keyset, maxwid
docs: Break a result set into subsets with the same keys.
  
          :param rs: Result set, rows of a result as a list of dicts
          :type rs: list of dict
          :return: A set with distinct keys (tuples), and a dict, by these tuples, of max. widths for each column