Skip to main content

Matrix

Apply a matrix of wrangles to the dataframe. This will run the wrangles for each combination of the variables.

Apply a matrix of wrangles to the dataframe. Each wrangle runs for the configured combinations of variables, including recipe variables and variables declared by the variables parameter.

See the Matrix connector for the connector equivalent.

Parameters​

NameDescriptionAccepted ValuesDefaultRequired
Options
strategyDetermines how to combine variables when there are multiple. loop (default) iterates over each set of variables, repeating shorter lists until the longest is completed. permutations uses the combination of all variables against all other variables.string; one of:
  • permutations
  • loop
"loop"No
Conditions
ifCondition that determines whether the wrangle runs as a whole. Recipe variables may be referenced with ${variable}.string—No
whereFilter rows before applying the wrangle using SQL-like criteria, such as column1 = 123 OR column2 = 'abc'.string—No
where_paramsValues used with where for parameterized criteria. Uses SQLite placeholder syntax such as ? or :name.array, object—No
Execution
variablesA dictionary of variables to pass to the wrangle. The key is the variable name and the value is a list of values.object—Yes
wranglesThe wrangles to apply to the dataframe. Each wrangle will be run for each combination of the variables.array—Yes

Examples​

Run a custom function once for each configured variable value.

wrangles:
- matrix:
variables:
var: [A, B, C]
wrangles:
- custom.test_fn:
input: Part Code
output: Part Code ${var}
value: ${var}
def test_fn(part_code, value):
return part_code + value
Part Code
6202
br549
554-114
554-112
Part Code APart Code BPart Code C
6202A6202B6202C
br549Abr549Bbr549C
554-114A554-114B554-114C
554-112A554-112B554-112C

This example runs extract.custom once for each unique model ID.

wrangles:
- matrix:
variables:
model_id: set(Model ID)
wrangles:
- extract.custom:
input: Description
output: Extracted Values
model_id: ${model_id}
where: "[Model ID] = ?"
where_params:
- ${model_id}
DescriptionModel ID
The SKF 6202 bearing is the best bearing in the worldxxxxxxxx-xxxx-xxxx
The Timken 6102 bearing is indestructibleyyyyyyyy-yyyy-yyyy
The Milwaukee impact has 1200ft-lbs of torquezzzzzzzz-zzzz-zzzz
Extracted Values
6202
indestructible
1200ft-lbs
VariableFunction
${column_count}Number of columns.
${columns}List of all columns.
${df}Current dataframe.
${row_count}Number of visible rows processed in each batch.
Access
RequirementValue
AI-poweredNo
Requires WrangleWorks accountNo
Requires subscriptionNo
Requires external API keyNo
Technical details
FieldValue
Catalog ID84
Catalog keymatrix
Recipe keymatrix
Catalog statusactive
Lifecycle statusactive
Recipe Writer eligibleNo
Recipe Writer exclusionMatrix orchestration is not supported in the baseline.
NamespaceRoot-level
Documentation grouputility
AliasesNone
Runtime symbolwrangles.recipe_wrangles.main.matrix
Legacy UUIDNone

Sources