class_docstr: This class defines a simple aggregator that groups metrics and applies an
  aggregating function. Grouping is determined by the set difference
  between an original `group_by` term and a subset `new_group_py` term.
class_docstr_tok: ["This","class","defines","a","simple","aggregator","that","groups","metrics","and","applies","an","aggregating","function",".","Grouping","is","determined","by","the","set","difference","between","an","original","`","group_by","`","term","and","a","subset","`","new_group_py","`","term","."]
docstr: For each unique value of pdf.loc[:,new_group_by], aggregate
  the values using self.func 
docstr_tok: ["For","each","unique","value","of","pdf.loc","[",":",",new_group_by","]",",","aggregate","the","values","using","self.func"]
code: def scalar_wrapper_(self, pdf):
      """For each unique value of pdf.loc[:,new_group_by], aggregate
      the values using self.func"""
      group = pdf.reset_index().groupby(
          by=self.new_group_by, group_keys=False
      )
  
      def func(pdf):
          agg = self.scalar_func(list(pdf.loc[:, self.key]))
          return pd.Series({self.name: agg})
  
      return [group.apply(func)]
  
imports: from __future__ import absolute_import, division, print_function
  import itertools
  from itertools import groupby
  from collections import defaultdict
  import pandas
  from niftynet.engine.application_factory import EvaluationFactory
  from niftynet.utilities.util_common import cache
label_desc: Use image node_id 2 for calling the ScalarAggregator obj's underlying member method code with example usage: obj.scalar_wrapper_(pdf) and returns: list, pd