docs: def sum_tbl(tbl, kfield, vfields):
      """
      Aggregate a composite array and compute the totals on a given key.
  
      >>> dt = numpy.dtype([('name', (bytes, 10)), ('value', int)])
      >>> tbl = numpy.array([('a', 1), ('a', 2), ('b', 3)], dt)
      >>> sum_tbl(tbl, 'name', ['value'])['value']
      array([3, 3])
      """
      pairs = [(n, tbl.dtype[n]) for n in [kfield] + vfields]
      dt = numpy.dtype(pairs + [('counts', int)])
  
      def sum_all(group):
          vals = numpy.zeros(1, dt)[0]
          for rec in group:
              for vfield in vfields:
                  vals[vfield] += rec[vfield]
              vals['counts'] += 1
          vals[kfield] = rec[kfield]
          return vals
      rows = groupby(tbl, operator.itemgetter(kfield), sum_all).values()
      array = numpy.zeros(len(rows), dt)
      for i, row in enumerate(rows):
          for j, name in enumerate(dt.names):
              array[i][name] = row[j]
      return array