#NEWLINE# def aggregate( table , metrics = None , by = None , having = None , **kwds ) : #NEWLINE# #INDENT# '\n    Aggregate a table with a given set of reductions, with grouping\n    expressions, and post-aggregation filters.\n\n    Parameters\n    ----------\n    table : table expression\n    metrics : expression or expression list\n    by : optional, default None\n      Grouping expressions\n    having : optional, default None\n      Post-aggregation filters\n\n    Returns\n    -------\n    agg_expr : TableExpr\n    ' #NEWLINE# if ( metrics is None ) : #NEWLINE# #INDENT# metrics = [ ] #NEWLINE# #UNINDENT# for ( k , v ) in sorted ( kwds . items ( ) ) : #NEWLINE# #INDENT# v = table . _ensure_expr ( v ) #NEWLINE# metrics . append ( v . name ( v ) ) #NEWLINE# #UNINDENT# op = table . op ( ) . aggregate ( table , metrics , by = by , having = having ) #NEWLINE# return TableExpr ( op )