docs-v2/content/flux/v0/stdlib/universe/getcolumn.md

2.2 KiB

title description menu weight flux/v0/tags introduced
getColumn() function `getColumn()` extracts a specified column from a table as an array.
flux_v0_ref
name parent identifier
getColumn universe universe/getColumn
101
dynamic queries
0.29.0

getColumn() extracts a specified column from a table as an array.

If the specified column is not present in the table, the function returns an error.

Function type signature
(<-table: stream[A], column: string) => [B] where A: Record

{{% caption %}} For more information, see Function type signatures. {{% /caption %}}

Parameters

column

({{< req >}}) Column to extract.

table

Input table. Default is piped-forward data (<-).

Examples

Extract an array of column values from a table

import "sampledata"

sampledata.int()
    |> tableFind(fn: (key) => key.tag == "t1")
    |> getColumn(column: "_value")// Returns [-2, 10, 7, 17, 15, 4]


Extract an array of column values and display them in a table

import "array"
import "sampledata"

columnData =
    sampledata.int()
        |> tableFind(fn: (key) => key.tag == "t1")
        |> getColumn(column: "_value")

array.from(rows: [{_value: display(v: columnData)}])