aggregate.table() function
aggregate.table()
is a user-contributed function maintained by
the package author and can
be updated or removed at any time.
aggregate.table()
will aggregate columns and create tables with a single
row containing the aggregated value.
Function type signature
(<-tables: stream[B], columns: A) => stream[C] where A: Record, B: Record, C: Record
Parameters
tables
Input data. Default is piped-forward data (<-
).
columns
(Required) Columns to aggregate and which aggregate method to use.
Columns is a record where the key is a column name and the value is an aggregate record. The aggregate record is composed of at least the following required attributes:
- column: Input column name (string).
- init: A function to compute the initial state of the
output. This can return either the final aggregate or a
temporary state object that can be used to compute the
final aggregate. The
values
parameter will always be a non-empty array of values from the specified column. For example:(values) => state
. - reduce: A function that takes in another buffer of values
and the current state of the aggregate and computes
the updated state.
For example:
(values, state) => state
. - compute: A function that takes the state and computes the final
aggregate. For example,
(state) => value
. - fill: The value passed to
fill()
. If present, the fill value determines what the aggregate does when there are no values. This can either be a value or one of the predefined identifiers ofnull
ornone
. This value must be the same type as the value return fromcompute
.
Examples
Compute the min of a specific column
import "sampledata"
import "contrib/jsternberg/aggregate"
sampledata.float()
|> aggregate.table(columns: {"min_bottom_degrees": aggregate.min(column: "_value")})
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, use the following resources:
InfluxDB Cloud customers can contact InfluxData Support.