Dictionary Element
Select one or more element of a dictionary.
Parameters
| Name | Description | Accepted Values | Default | Required |
|---|---|---|---|---|
| I/O | ||||
input | Name of the input column. | string, integer, array | — | Yes |
output | Name of the output column. If omitted, the input column will be replaced. | string, array, null | null | No |
| Options | ||||
element | The key or keys from the dictionary to select. If a single key is provided, the value will be returned If a lists of keys are selected, the result will be a new dictionary. | string | — | Yes |
| 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 |
| Errors | ||||
default | Set the default value to return if the specified element doesn't exist. If selecting multiple elements, a dict of defaults can be set. | string, number, array, object, boolean, null | "" | No |
Examples
wrangles:
- select.dictionary_element:
input: Properties
output: Shapes
element: shapes
default: square
where: Part Number = 1234
| Properties | Part Number |
|---|---|
| {'colours': ['red', 'white', 'blue'], 'shapes': 'round', 'materials': 'tungsten'} | 1234 |
| {'colours': ['green', 'yellow', 'orange'], 'shapes': 'square', 'materials': 'tungsten'} | 5678 |
| Shapes |
|---|
| round |
wrangles:
- select.dictionary_element:
input: Properties
element:
- shapes
- materials
| Properties |
|---|
| {'colours': ['red', 'white', 'blue'], 'shapes': 'round', 'materials': 'tungsten'} |
| {'colours': ['green', 'yellow', 'orange'], 'shapes': 'square', 'materials': 'tungsten'} |
| Properties |
|---|
| {'shapes': 'round', 'materials': 'tungsten'} |
| {'shapes': 'square', 'materials': 'tungsten'} |
wrangles:
- select.dictionary_element:
input: Properties
output: Output Dict
element:
- Col*
| Column |
|---|
| {'Col1': 'A', 'Col2': 'B', 'Other3': 'C'} |
| Column | Output Dict |
|---|---|
| {'Col1': 'A', 'Col2': 'B', 'Col3': 'C'} | {'Col1': 'A', 'Col2': 'B'} |
wrangles:
- select.dictionary_element:
input: Properties
output: Output Dict
element:
- "regex: .*2"
| Column |
|---|
| {'Col1': 'A', 'Col2': 'B', 'Col3': 'C'} |
| Output Dict |
|---|
| {'Col2': 'B'} |
wrangles:
- select.dictionary_element:
input: Properties
output: Output Dict
element:
- Col1: Column 1
- Col2: Column 2
| Column |
|---|
| {'Col1': 'A', 'Col2': 'B', 'Col3': 'C'} |
| Output Dict |
|---|
| {'Column 1': 'A', 'Column 2': 'B'} |
wrangles:
- select.dictionary_element:
input: Properties
output: Output Dict
element:
- Col1
- Col3
default:
Col1: Z
Col3: Y
| Column |
|---|
| {'Col1': 'A', 'Col2': 'B', 'Col3': 'C'} |
| {'Col1': 'D', 'Col2': 'E'} |
| Output Dict |
|---|
| {'Col1': 'A', 'Col3': 'C'} |
| {'Col1': 'D', 'Col3': 'Y'} |
Access
| Requirement | Value |
|---|---|
| AI-powered | No |
| Requires WrangleWorks account | No |
| Requires subscription | No |
| Requires external API key | No |
Technical details
| Field | Value |
|---|---|
| Catalog ID | 50 |
| Catalog key | select.dictionary_element |
| Recipe key | select.dictionary_element |
| Catalog status | active |
| Lifecycle status | active |
| Recipe Writer eligible | Yes |
| Namespace | select |
| Documentation group | select |
| Aliases | None |
| Runtime symbol | wrangles.recipe_wrangles.select.dictionary_element |
| Legacy UUID | 5adaeada-6da8-464f-84cb-9fb5ecc17e48 |
Sources