summarize
Synopsis
any |> summarize <fields>... [name: value]...
Description
summarize gives one summary record per field in fields, and per group
when by is given, with the fields field, count, sum, min, max and
average; with by, the record starts with the group value under the name
of the by field.
count is the number of values other than null; null values are
skipped. Integers and numbers sum to an integer or a number and average to a
number. Sizes and durations sum and average in their own unit, rounded to
whole bytes and milliseconds. For text and other types, and for fields that
mix types, sum and average are null and min and max follow the
total order of values.
Without fields, each group gives one record with the number of its records
in count. Groups are ordered by their value. An empty input without by
gives one record per field with count 0.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
fields |
list<field> |
none | Numeric fields to summarize. |
by |
field |
none | Field whose value forms the groups. |
Input and output
| Form | Input | Output |
|---|---|---|
| default | any |
summary |
Effect
| Property | Value |
|---|---|
| Category | transform |
| Effect | read |
| Reversibility | read |
| Implementation | builtin |
Examples
Compute the total and average size of the files of a project:
find "/home/user/project" |> summarize size
Compute the size statistics per extension:
find "/home/user/project" |> summarize size by: extension
Count the files per extension:
find "/home/user/project" |> summarize by: extension
Errors
| Code | Meaning | Typical fix |
|---|---|---|
E_UNKNOWN_FIELD |
a field is not in the records; expected lists their fields |
use one of the listed fields |
E_LIMIT |
more groups than the limit | group by a field with fewer values |
Related
group, count, distinct.