Skip to main content
Version: Python

agg_all_by

agg_all_by creates a new table containing grouping columns and grouped data. The resulting grouped data is defined by the aggregation specified.

note

Because agg_all_by applies the aggregation to all the columns of the table, it will ignore any column names specified for the aggregation.

Syntax

agg_all_by(agg: Aggregation, by: Sequence[str] = None) -> Table

Parameters

ParameterTypeDescription
aggAggregation

The aggregation to apply to all columns of the source table.

by optionalSequence[str]

The grouping column names. Set to None by default.

Returns

A new table containing grouping columns and grouped data.

Examples

In this example, agg_all_by returns the median of "Number" values, grouped by X.

from deephaven import new_table
from deephaven.column import string_col, int_col, double_col
from deephaven import agg
from deephaven import table

source = new_table(
[
string_col(
"X",
[
"A",
"B",
"A",
"C",
"B",
"A",
"B",
"B",
"A",
"A",
"B",
"A",
"C",
"B",
"A",
"B",
"B",
"C",
],
),
string_col(
"Y",
[
"M",
"N",
"M",
"N",
"N",
"M",
"O",
"P",
"N",
"M",
"N",
"M",
"N",
"N",
"M",
"O",
"P",
"N",
],
),
int_col(
"Number",
[
55,
76,
55,
130,
230,
50,
76,
137,
214,
55,
76,
55,
130,
230,
50,
76,
137,
214,
],
),
]
)

result = source.agg_all_by(agg=agg.median(), by="X")