def derive_aggregation(dim_cols, agg_col, agg):
 if ((dim_cols == 'index') or (agg_col == 'index') or (dim_cols is None)):
  agg = None
  agg_col = None
 elif (agg_col is None):
  if isinstance(dim_cols, list):
   agg_col = dim_cols[0]
  else:
   agg_col = dim_cols
  agg = 'count'
 return (agg_col, agg)

def derive_aggregation ( dim_cols , agg_col , agg ) : if ( ( dim_cols == 'index' ) or ( agg_col == 'index' ) or ( dim_cols is None ) ) : agg = None agg_col = None elif ( agg_col is None ) : if isinstance ( dim_cols , list ) : agg_col = dim_cols [ 0 ] else : agg_col = dim_cols agg = 'count' return ( agg_col , agg )
produces consistent aggregation spec from optional column specification .