code: def as_table(self, fn=None, col=None, col_label=None):
          if col_label is None:
              col_label = col
          if fn is None:
              fn = len
              if col_label is None:
                  col_label = 'count'
          ret = Table()
          do_all(ret.create_index(attr) for attr in self._pivot_attrs)
          if len(self._pivot_attrs) == 1:
              for sub in self.subtables:
                  subattr, subval = sub._attr_path[-1]
                  attrdict = {subattr: subval}
                  if col is None or fn is len:
                      attrdict[col_label] = fn(sub)
                  else:
                      attrdict[col_label] = fn(s[col] for s in sub)
                  ret.insert(DataObject(**attrdict))
          elif len(self._pivot_attrs) == 2:
              for sub in self.subtables:
                  for ssub in sub.subtables:
                      attrdict = dict(ssub._attr_path)
                      if col is None or fn is len:
                          attrdict[col_label] = fn(ssub)
                      else:
                          attrdict[col_label] = fn(s[col] for s in ssub)
                      ret.insert(DataObject(**attrdict))
          elif len(self._pivot_attrs) == 3:
              for sub in self.subtables:
                  for ssub in sub.subtables:
                      for sssub in ssub.subtables:
                          attrdict = dict(sssub._attr_path)
                          if col is None or fn is len:
                              attrdict[col_label] = fn(sssub)
                          else:
                              attrdict[col_label] = fn(s[col] for s in sssub)
                          ret.insert(DataObject(**attrdict))
          else:
              raise ValueError("can only dump summary counts for 1 or 2-attribute pivots")
          return ret