map

utility

Transforms array elements

Syntax

map(array, field|template)

Parameters

array (array)

The array to transform (implicit when used in pipeline)

field (expression)

Field name or transformation expression

Returns

array

Transformed array

Examples

Extract names
Input:
map(.name)
Output:
["Alice", "Bob", "Charlie"]
Keep specific fields
Input:
map({name, age})
Output:
[{name: "Alice", age: 30}, {name: "Bob", age: 25}]
Double all values
Input:
map(. * 2)
Output:
[2, 4, 6, 8]

The map() function transforms each element in an array using a specified expression or template.

Usage

Use map() to extract fields, transform data, or apply operations to every element in an array or DataFrame.

Related Functions