EXPAND ALL
  • Home

DataFrame.agg

Aggregates the data based on the expressions.

Computes the aggregate expressions on the data. If the preceding operator is a groupby, then we evaluate the aggregate expression in each group. If not, we calculate the aggregate expression using all of the preceding data. If no arguments specified and the call follows a grouped DataFrame, then agg() returns the unique groups. If following a non-grouped DataFrame agg() with no args will yield a compilation error. Each aggregate expression is simply the aggregate function applied to a column, formatted as <out_col_name>=("<column_name>", <function>). A list of functions are available in the UDA docs

Arguments

NameTypeDescription
**kwargsTuple[string, AggFn]The column, aggregate function pair that make up the expression to apply, assigned to the output column name. `<out_col_name>=("<column_name>", <function>)`. If this value is empty, it will return the unique groups in the previous DataFrame.

Returns

px.DataFrame: DataFrame with aggregated expressions evaluated containing the groups (if any) followed by the output column aggregate expression names.

Examples

# Group by UPID and calculate maximum user time for the each
# UPID group.
df = px.DataFrame('process_stats')
df = df.groupby('upid').agg(cpu_utime=('cpu_utime_ns', px.max))

This site uses cookies to provide you with a better user experience. By using Pixie, you consent to our use of cookies.