def _groupby_apply_funcs(df, *index, **kwargs):
 if len(index):
  kwargs.update(by=list(index))
 funcs = kwargs.pop('funcs')
 grouped = df.groupby(**kwargs)
 result = collections.OrderedDict()
 for (result_column, func, func_kwargs) in funcs:
  result[result_column] = func(grouped, **func_kwargs)
 return pd.DataFrame(result)

def _groupby_apply_funcs ( df , * index , ** kwargs ) : if len ( index ) : kwargs . update ( by = list ( index ) ) funcs = kwargs . pop ( 'funcs' ) grouped = df . groupby ( ** kwargs ) result = collections . OrderedDict ( ) for ( result_column , func , func_kwargs ) in funcs : result [ result_column ] = func ( grouped , ** func_kwargs ) return pd . DataFrame ( result )
group a dataframe and apply multiple aggregation functions .