Skip to main content

Utility Wrangles

Utility wrangles, with recipe examples, parameters, and behavior.

Accordion​

Apply a series of wrangles to column(s) containing lists. The wrangles will be applied to each element in the list and the results will be returned back as a list.

Apply a series of wrangles to the individual elements of one or more lists.

Parameters​

NameDescriptionAccepted ValuesDefaultRequired
I/O
inputThe column(s) containing the list(s) that the wrangles will be applied to the elements of.string, integer, array—Yes
outputOutput of the wrangles to save back to the dataframe.string, array, nullnullNo
propagateLimit the column(s) that will be available to the wrangles and replicated for each element. If not specified, all columns will be propogated. This may be useful to limit the memory use for large datasets.string, array, nullnullNo
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
wranglesList of wrangles to apply.array—Yes

Examples​

This example applies convert.case to each string in a list, where the wrangle would not normally operate on the list as a whole.

wrangles:
- accordion:
input: list_column
output: modified_lists
wrangles:
- convert.case:
input: list_column
output: modified_lists
case: upper
list_column
["a", "b", "c"]
["e", "f", "g"]
modified_lists
["A", "B", "C"]
["E", "F", "G"]
Access
RequirementValue
AI-poweredNo
Requires WrangleWorks accountNo
Requires subscriptionNo
Requires external API keyNo
Technical details
FieldValue
Catalog ID69
Catalog keyaccordion
Recipe keyaccordion
Catalog statusactive
Lifecycle statusactive
Recipe Writer eligibleNo
Recipe Writer exclusionNested-list orchestration is not supported in the baseline.
NamespaceRoot-level
Documentation grouputility
AliasesNone
Runtime symbolwrangles.recipe_wrangles.main.accordion
Legacy UUIDNone

Sources


Batch​

Split the data into batches for executing a list of wrangles. Use this in situations such as where the intermediate data is too large to fit in memory.

Execute a series of wrangles in batches. Batches can run in parallel with threads and can provide fallback output when an error occurs.

Parameters​

NameDescriptionAccepted ValuesDefaultRequired
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
wranglesThe wrangles to execute on the data. Each series of wrangles will be run against the data in batches of the size defined by batch_size.array—Yes
batch_sizeThe number of rows to split each batch into.integer1000No
threadsThe number of threads to use for parallel processing. Default 1.integer1No
timeoutThe number of seconds to wait for a batch to complete before raising an error.number, nullnullNo
use_multiprocessingUse process-based workers instead of threads. This is an advanced runtime option.booleanfalseNo
Errors
on_errorA dictionary of column_name: value to return if an error occurs while attempting to run a batch.object, nullnullNo

Examples​

This example processes product descriptions in batches of two rows.

wrangles:
- batch:
batch_size: 2
threads: 1
wrangles:
- extract.ai:
api_key: Your OpenAI API key
input: Product Description
output:
Title:
type: string
description: Title of the product
Product Description
Sleep better with our Memory Foam Pillow, designed to contour to your head and neck.
Stay comfortable and stylish with our Organic Cotton T-Shirt, made from soft, breathable fabric.
Keep drinks hot or cold with our Stainless Steel Water Bottle, featuring durable insulation.
Enjoy crisp sound and long battery life with our Wireless Bluetooth Earbuds.
Title
Memory Foam Pillow
Organic Cotton T-Shirt
Stainless Steel Water Bottle
Wireless Bluetooth Earbuds
Access
RequirementValue
AI-poweredNo
Requires WrangleWorks accountNo
Requires subscriptionNo
Requires external API keyNo
Technical details
FieldValue
Catalog ID70
Catalog keybatch
Recipe keybatch
Catalog statusactive
Lifecycle statusactive
Recipe Writer eligibleYes
NamespaceRoot-level
Documentation grouputility
AliasesNone
Runtime symbolwrangles.recipe_wrangles.main.batch
Legacy UUIDNone

Sources


Concurrent​

Run multiple wrangles concurrently rather than sequentially. Wrangles must specify output columns to be used concurrently. When using concurrent, Wrangles may not complete in a predictable order and it is not recommended to update overlapping columns with different wrangles.

Run multiple wrangles concurrently instead of sequentially. Concurrent wrangles must declare output columns, may finish in any order, and should not update overlapping columns.

See the Concurrent connector for the connector equivalent.

Parameters​

NameDescriptionAccepted ValuesDefaultRequired
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
wranglesThe wrangles section of a recipe to execute for each combination of variables.array—Yes
max_concurrencyThe maximum number of wrangles to execute in parallel.integer10No
use_multiprocessingUse process-based workers instead of threads. This is an advanced runtime option.booleanfalseNo

Examples​

wrangles:
- concurrent:
wrangles:
- extract.codes:
input: Products
output: Part Codes
- extract.attributes:
input: Products
output: Attributes
Products
SKF ball brg 2" od 6202
brg seal 1" id 5493
3lb hammer 87102
Part CodesAttributes
6202{"length":["2in"]}
5493{"length":["1in"]}
87102{"weight":["3lb"]}
Access
RequirementValue
AI-poweredNo
Requires WrangleWorks accountNo
Requires subscriptionNo
Requires external API keyNo
Technical details
FieldValue
Catalog ID73
Catalog keyconcurrent
Recipe keyconcurrent
Catalog statusactive
Lifecycle statusactive
Recipe Writer eligibleNo
Recipe Writer exclusionConcurrent orchestration is not supported in the baseline.
NamespaceRoot-level
Documentation grouputility
AliasesNone
Runtime symbolwrangles.recipe_wrangles.main.concurrent
Legacy UUIDNone

Sources


Log​

Log the current status of the dataframe.

Print the current status of the dataframe. Only a sample of rows is logged.

Parameters​

NameDescriptionAccepted ValuesDefaultRequired
I/O
columns(Optional, default all columns) List of specific columns to log.array, nullnullNo
Options
write(Optional) Allows for an intermediate output to a file/dataframe/database etc.array, nullnullNo
warningLog a warning to the console.string, nullnullNo
infoLog info to the console.string, nullnullNo
log_dataWhether to log a sample of the contents of the dataframe. Default True if not logging to a write, error, warning or info. Default False otherwise.boolean, nullnullNo
errorLog an error to the console.string—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

Examples​

wrangles:
- log: {}

Logging side-effect; no tabular input sample.

Logs a sample of rows or status information to the configured destination.

wrangles:
- log:
columns:
- column1
- column2

Logging side-effect; no tabular input sample.

Logs a sample of rows or status information to the configured destination.

wrangles:
- log:
write:
- file:
name: output/filepath
columns:
- column 1
- column 2

Logging side-effect; no tabular input sample.

Logs a sample of rows or status information to the configured destination.

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 ID80
Catalog keylog
Recipe keylog
Catalog statusactive
Lifecycle statusactive
Recipe Writer eligibleNo
Recipe Writer exclusionOperational logging steps are not authored in the baseline.
NamespaceRoot-level
Documentation grouputility
AliasesNone
Runtime symbolwrangles.recipe_wrangles.main.log
Legacy UUID6177808e-aa2d-4d0b-8385-858b16948a5d

Sources


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


Recipe​

Run another recipe as a wrangle against the current dataframe.

Behavior​

Run another recipe as a wrangle against the current dataframe.

This guidance was derived from the callable signature and its embedded Python schema docstring.

Parameters​

NameDescriptionAccepted ValuesDefaultRequired
I/O
inputName, index, or list of input columns.string, integer, array, nullnullNo
outputName or list of output columns.string, array, nullnullNo
Options
nameFile name of the recipe.string, nullnullNo
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 recipe.object, nullnullNo
Access
RequirementValue
AI-poweredNo
Requires WrangleWorks accountNo
Requires subscriptionNo
Requires external API keyNo
Technical details
FieldValue
Catalog ID86
Catalog keyrecipe
Recipe keyrecipe
Catalog statusactive
Lifecycle statusactive
Recipe Writer eligibleNo
Recipe Writer exclusionNested recipe composition is outside the baseline.
NamespaceRoot-level
Documentation grouputility
AliasesNone
Runtime symbolwrangles.recipe_wrangles.main.recipe
Legacy UUIDNone

Sources


Try​

Try a list of wrangles and catch any errors that occur.

Run a list of wrangles and catch errors. When except is provided, its wrangles or fallback column values run after an error; otherwise, the error is logged and the recipe continues.

Parameters​

NameDescriptionAccepted ValuesDefaultRequired
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
wranglesList of wrangles to apply.array—Yes
Errors
retriesNumber of times to retry the wrangles if an error occurs. Default 0.integer0No
exceptAn action to take if the wrangles encounter an error. This can contain a list of wrangles or a dictionary of column names and values. If except is not provided, the error will be logged and the recipe will continue.object—No

Examples​

wrangles:
- try:
wrangles:
- risky_wrangle:
input: column
except:
- backup_wrangle:
input: column

The input dataframe is passed to the primary wrangles.

The primary result is returned on success; the except result is returned after an error.

Access
RequirementValue
AI-poweredNo
Requires WrangleWorks accountNo
Requires subscriptionNo
Requires external API keyNo
Technical details
FieldValue
Catalog ID98
Catalog keytry
Recipe keytry
Catalog statusactive
Lifecycle statusactive
Recipe Writer eligibleNo
Recipe Writer exclusionError-control orchestration is not supported in the baseline.
NamespaceRoot-level
Documentation grouputility
AliasesNone
Runtime symbolwrangles.recipe_wrangles.main.Try
Legacy UUIDNone

Sources