<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def prune_by_work_count(self, minimum=None, maximum=None, label=None):
 """Removes results rows for n-grams that are not attested in a number of works in the range specified by `minimum` and `maximum`. Work here encompasses all witnesses, so that the same n-gram appearing in multiple witnesses of the same work are counted as a single work. If `label` is specified, the works counted are restricted to those associated with `label`. :param minimum: minimum number of works :type minimum: `int` :param maximum: maximum number of works :type maximum: `int` :param label: optional label to restrict requirement to :type label: `str` """

        self._logger.info('Pruning results by work count')
        count_fieldname = 'tmp_count'
        matches = self._matches
        if label is not None:
            matches = matches[matches[constants.LABEL_FIELDNAME] == label]
        filtered = matches[matches[constants.COUNT_FIELDNAME] > 0]
        grouped = filtered.groupby(constants.NGRAM_FIELDNAME, sort=False)
        counts = pd.DataFrame(grouped[constants.WORK_FIELDNAME].nunique())
        counts.rename(columns={constants.WORK_FIELDNAME: count_fieldname},
                      inplace=True)
        if minimum:
            counts = counts[counts[count_fieldname] >= minimum]
        if maximum:
            counts = counts[counts[count_fieldname] <= maximum]
        self._matches = pd.merge(self._matches, counts,
                                 left_on=constants.NGRAM_FIELDNAME,
                                 right_index=True)
        del self._matches[count_fieldname]