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
| Name | Description | Accepted Values | Default | Required |
|---|---|---|---|---|
| Options | ||||
strategy | Determines 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:
| "loop" | No |
| Conditions | ||||
if | Condition that determines whether the wrangle runs as a whole. Recipe variables may be referenced with ${variable}. | string | — | No |
where | Filter rows before applying the wrangle using SQL-like criteria, such as column1 = 123 OR column2 = 'abc'. | string | — | No |
where_params | Values used with where for parameterized criteria. Uses SQLite placeholder syntax such as ? or :name. | array, object | — | No |
| Execution | ||||
variables | A dictionary of variables to pass to the wrangle. The key is the variable name and the value is a list of values. | object | — | Yes |
wrangles | The 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 A | Part Code B | Part Code C |
|---|---|---|
| 6202A | 6202B | 6202C |
| br549A | br549B | br549C |
| 554-114A | 554-114B | 554-114C |
| 554-112A | 554-112B | 554-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}
| Description | Model ID |
|---|---|
| The SKF 6202 bearing is the best bearing in the world | xxxxxxxx-xxxx-xxxx |
| The Timken 6102 bearing is indestructible | yyyyyyyy-yyyy-yyyy |
| The Milwaukee impact has 1200ft-lbs of torque | zzzzzzzz-zzzz-zzzz |
| Extracted Values |
|---|
| 6202 |
| indestructible |
| 1200ft-lbs |
| Variable | Function |
|---|---|
${column_count} | Number of columns. |
${columns} | List of all columns. |
${df} | Current dataframe. |
${row_count} | Number of visible rows processed in each batch. |
Access
| Requirement | Value |
|---|---|
| AI-powered | No |
| Requires WrangleWorks account | No |
| Requires subscription | No |
| Requires external API key | No |
Technical details
| Field | Value |
|---|---|
| Catalog ID | 84 |
| Catalog key | matrix |
| Recipe key | matrix |
| Catalog status | active |
| Lifecycle status | active |
| Recipe Writer eligible | No |
| Recipe Writer exclusion | Matrix orchestration is not supported in the baseline. |
| Namespace | Root-level |
| Documentation group | utility |
| Aliases | None |
| Runtime symbol | wrangles.recipe_wrangles.main.matrix |
| Legacy UUID | None |
Sources