Setvariables¶
flowtask.components.SetVariables
¶
SetVariables
¶
Bases: FlowComponent
SetVariables
Overview
The SetVariables class is a component for extracting values from data and setting them as variables
for use in other components. This component can set variables based on specific column values in
a DataFrame or by executing functions, with support for date formatting and value aggregation.
.. table:: Properties
:widths: auto
+----------------+----------+-----------+---------------------------------------------------------------+
| Name | Required | Summary |
+----------------+----------+-----------+---------------------------------------------------------------+
| vars | Yes | Dictionary defining variables to set with options for format, |
| | | row selection, and data sources. |
+----------------+----------+-----------+---------------------------------------------------------------+
Returns
This component returns the original data after setting variables based on the `vars` dictionary.
Each variable is created from a specified column or function, and supports formatting options
such as date, timestamp, epoch, or custom string formatting. Metrics are recorded for each variable
set, and any issues with variable definitions or data retrieval raise a descriptive `ComponentError`.
Example:
```yaml
SetVariables:
vars:
max_date:
- order_date
- row: max
min_date:
- order_date
- row: min
```