def _normalize_spec(spec, non_group_columns):
 if (not isinstance(spec, dict)):
  spec = collections.OrderedDict(zip(non_group_columns, it.repeat(spec)))
 res = []
 if isinstance(spec, dict):
  for (input_column, subspec) in spec.items():
   if isinstance(subspec, dict):
    res.extend((((input_column, result_column), func, input_column) for (result_column, func) in subspec.items()))
   else:
    if (not isinstance(subspec, list)):
     subspec = [subspec]
    res.extend((((input_column, funcname(func)), func, input_column) for func in subspec))
 else:
  raise ValueError('unsupported agg spec of type {}'.format(type(spec)))
 compounds = (list, tuple, dict)
 use_flat_columns = (not any((isinstance(subspec, compounds) for subspec in spec.values())))
 if use_flat_columns:
  res = [(input_col, func, input_col) for (_, func, input_col) in res]
 return res

def _normalize_spec ( spec , non_group_columns ) : if ( not isinstance ( spec , dict ) ) : spec = collections . OrderedDict ( zip ( non_group_columns , it . repeat ( spec ) ) ) res = [ ] if isinstance ( spec , dict ) : for ( input_column , subspec ) in spec . items ( ) : if isinstance ( subspec , dict ) : res . extend ( ( ( ( input_column , result_column ) , func , input_column ) for ( result_column , func ) in subspec . items ( ) ) ) else : if ( not isinstance ( subspec , list ) ) : subspec = [ subspec ] res . extend ( ( ( ( input_column , funcname ( func ) ) , func , input_column ) for func in subspec ) ) else : raise ValueError ( 'unsupported agg spec of type {}' . format ( type ( spec ) ) ) compounds = ( list , tuple , dict ) use_flat_columns = ( not any ( ( isinstance ( subspec , compounds ) for subspec in spec . values ( ) ) ) ) if use_flat_columns : res = [ ( input_col , func , input_col ) for ( _ , func , input_col ) in res ] return res
return a list of tuples .