Excerpt |
---|
Combines multiple arrays into a single nested array, with element 1 of array 1 paired with element 2 of array 2 and so on. Arrays are expressed as column names or as array literals. |
If the arrays are of different length, then null values are inserted for combinations where one array is missing a corresponding value.
Array literal reference example:
D lang syntax |
---|
RawWrangle | true |
---|
Type | ref |
---|
showNote | true |
---|
WrangleText | derive type:single value:arrayzip([["A","B","C"],["1","2","3"]] ) |
---|
|
arrayzip([["A","B","C"],["1","2","3"]] ) |
Output: Returns a nested array combining elements from the two source arrays.
Column reference example:
D lang syntax |
---|
RawWrangle | true |
---|
Type | ref |
---|
showNote | true |
---|
WrangleText | derive type:single value:arrayzip([array1,array2]) as:'zippedArray' |
---|
|
arrayzip([array1,array2]) |
Output: Returns a single nested array pairing the elements of the array in the listed order of the arrays.
D lang syntax |
---|
RawWrangle | true |
---|
Type | syntax |
---|
showNote | true |
---|
WrangleText | derive type:single value:arrayzip(array_ref1,array_ref2) |
---|
|
arrayzip(array_ref1,array_ref2) |
Argument | Required? | Data Type | Description |
---|
array_ref1 | Y | string or array | Name of first column or first array literal to apply to the function |
array_ref2 | Y | string or array | Name of second column or second array literal to apply to the function |
array_ref1, array_ref2
Array literal or name of the array column whose elements you want to combine together.
Required? | Data Type | Example Value |
---|
Yes | Array literal or column reference | myArray1 , myArray2 |
Example - Simple ARRAYZIP example
Source:
Item | Letters | Numerals |
---|
Item1 | ["A","B","C"] | ["1","2","3"] |
Item2 | ["D","E","F"] | ["4","5","6"] |
Item3 | ["G","H","I"] | ["7","8","9"] |
Transformation:
D trans |
---|
RawWrangle | true |
---|
p03Value | 'LettersAndNumerals' |
---|
Type | step |
---|
WrangleText | derive type:single value:arrayzip([Letters,Numerals]) as:'LettersAndNumerals' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | arrayzip([Letters,Numerals]) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
Results:
Item | Letters | Numerals | LettersAndNumerals |
---|
Item1 | ["A","B","C"] | ["1","2","3"] | [["A","1"],["B",2"],["C","3"]] |
Item2 | ["D","E","F"] | ["4","5","6"] | [["F","4"],["G",5"],["H","6"]] |
Item3 | ["G","H","I"] | ["7","8","9"] | [["G","7"],["H",8"],["I","9"]] |
Example - Unnest an array
Include Page |
---|
| EXAMPLE - Flatten and Unnest Transforms |
---|
| EXAMPLE - Flatten and Unnest Transforms |
---|
|