<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_ngram_count_per_work(self, minimum=None, maximum=None, label=None):
 """Removes results rows if the n-gram count for all works bearing that n-gram is outside the range specified by `minimum` and `maximum`. That is, if a single witness of a single work has an n-gram count that falls within the specified range, all result rows for that n-gram are kept. If `label` is specified, the works checked are restricted to those associated with `label`. :param minimum: minimum n-gram count :type minimum: `int` :param maximum: maximum n-gram count :type maximum: `int` :param label: optional label to restrict requirement to :type label: `str` """

        self._logger.info('Pruning results by n-gram count per work')
        matches = self._matches
        keep_ngrams = matches[constants.NGRAM_FIELDNAME].unique()
        if label is not None:
            matches = matches[matches[constants.LABEL_FIELDNAME] == label]
        if minimum and maximum:
            keep_ngrams = matches[
                (matches[constants.COUNT_FIELDNAME] >= minimum) &
                (matches[constants.COUNT_FIELDNAME] <= maximum)][
                    constants.NGRAM_FIELDNAME].unique()
        elif minimum:
            keep_ngrams = matches[
                matches[constants.COUNT_FIELDNAME] >= minimum][
                    constants.NGRAM_FIELDNAME].unique()
        elif maximum:
            keep_ngrams = matches[
                self._matches[constants.COUNT_FIELDNAME] <= maximum][
                    constants.NGRAM_FIELDNAME].unique()
        self._matches = self._matches[self._matches[
            constants.NGRAM_FIELDNAME].isin(keep_ngrams)]