#NEWLINE# def apply( self , data ) : #NEWLINE# #INDENT# data_copy = copy ( data ) #NEWLINE# if ( self . columns is None ) : #NEWLINE# #INDENT# self . stat = stats [ 'count' ] ( ) #NEWLINE# #UNINDENT# stat = self . stat #NEWLINE# agg_name = '' #NEWLINE# if ( self . columns is not None ) : #NEWLINE# #INDENT# agg_name += ( self . columns [ 0 ] + '_' ) #NEWLINE# #UNINDENT# agg_name += self . stat . __class__ . __name__ #NEWLINE# self . agg_column = agg_name #NEWLINE# if ( self . columns is None ) : #NEWLINE# #INDENT# col = data_copy . columns [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# col = self . columns [ 0 ] #NEWLINE# #UNINDENT# def stat_func( group ) : #NEWLINE# #INDENT# stat . set_data ( group [ col ] ) #NEWLINE# group [ agg_name ] = stat . value #NEWLINE# return group #NEWLINE# #UNINDENT# gb = data_copy . groupby ( self . dimensions ) #NEWLINE# agg = gb . apply ( stat_func ) #NEWLINE# return stat_func