docs: def collect(self):
          """
          After adding the desired aggregation columns, `collect`
          finalizes the groupby operation by converting the
          GroupbyTable into a DataTable.
  
          The first columns of the resulting table are the groupfields,
          followed by the aggregation columns specified in preceeding
          `agg` calls.
          """
          # The final order of columns is determined by the
          # group keys and the aggregation columns
          final_field_order = list(self.__groupfields) + self.__grouptable.fields
  
          # Transform the group key rows into columns
          col_values = izip(*self.__grouptable['groupkey'])
  
          # Assign the columns to the table with the relevant name
          for groupfield, column in izip(self.__groupfields, col_values):
              self.__grouptable[groupfield] = column
  
          # Reorder the columns as defined above
          self.__grouptable.reorder(final_field_order)
  
          del self.__grouptable['groupkey']
          return self.__grouptable