docs: def group_by_witness(self):
          """Groups results by witness, providing a single summary field giving
          the n-grams found in it, a count of their number, and the count of
          their combined occurrences."""
          if self._matches.empty:
              # Ensure that the right columns are used, even though the
              # results are empty.
              self._matches = pd.DataFrame(
                  {}, columns=[constants.WORK_FIELDNAME,
                               constants.SIGLUM_FIELDNAME,
                               constants.LABEL_FIELDNAME,
                               constants.NGRAMS_FIELDNAME,
                               constants.NUMBER_FIELDNAME,
                               constants.TOTAL_COUNT_FIELDNAME])
              return
  
          def witness_summary(group):
              matches = group.sort_values(by=[constants.NGRAM_FIELDNAME],
                                          ascending=[True])
              match = matches.iloc[0]
              ngrams = ', '.join(list(matches[constants.NGRAM_FIELDNAME]))
              match[constants.NGRAMS_FIELDNAME] = ngrams
              match[constants.NUMBER_FIELDNAME] = len(matches)
              match[constants.TOTAL_COUNT_FIELDNAME] = matches[
                  constants.COUNT_FIELDNAME].sum()
              return match
  
          group_cols = [constants.WORK_FIELDNAME, constants.SIGLUM_FIELDNAME]
          # Remove zero-count results.
          self._matches = self._matches[
              self._matches[constants.COUNT_FIELDNAME] != 0]
          self._matches = self._matches.groupby(group_cols, sort=False).apply(
              witness_summary)
          del self._matches[constants.NGRAM_FIELDNAME]
          del self._matches[constants.SIZE_FIELDNAME]
          del self._matches[constants.COUNT_FIELDNAME]