About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
Last updated: Feb 11, 2025
The Derive node modifies data values or creates new fields from one or more
existing fields. It creates fields of type formula, flag, nominal, state, count, and
conditional.
Example 1
# Create and configure a Flag Derive field node
node = stream.create("derive", "My node")
node.setPropertyValue("new_name", "DrugX_Flag")
node.setPropertyValue("result_type", "Flag")
node.setPropertyValue("flag_true", "1")
node.setPropertyValue("flag_false", "0")
node.setPropertyValue("flag_expr", "'Drug' == \"drugX\"")
# Create and configure a Conditional Derive field node
node = stream.create("derive", "My node")
node.setPropertyValue("result_type", "Conditional")
node.setPropertyValue("cond_if_cond", "@OFFSET(\"Age\", 1) = \"Age\"")
node.setPropertyValue("cond_then_expr", "(@OFFSET(\"Age\", 1) = \"Age\" >< @INDEX")
node.setPropertyValue("cond_else_expr", "\"Age\"")
Example 2
This script assumes that there are two numeric columns called
and XPos
that represent the X and Y coordinates of a point
(for example, where an event took place). The script creates a Derive node that computes a
geospatial column from the X and Y coordinates representing that point in a specific coordinate
system:YPos
stream = modeler.script.stream()
# Other stream configuration code
node = stream.createAt("derive", "Location", 192, 96)
node.setPropertyValue("new_name", "Location")
node.setPropertyValue("formula_expr", "['XPos', 'YPos']")
node.setPropertyValue("formula_type", "Geospatial")
# Now we have set the general measurement type, define the
# specifics of the geospatial object
node.setPropertyValue("geo_type", "Point")
node.setPropertyValue("has_coordinate_system", True)
node.setPropertyValue("coordinate_system", "ETRS_1989_EPSG_Arctic_zone_5-47")
properties |
Data type | Property description |
---|---|---|
|
string | Name of new field. |
|
|
Specifies single or multiple fields. |
|
list | Used in Multiple mode only to select multiple fields. |
|
string | Specifies the extension for the new field name(s). |
|
|
Adds the extension as a prefix (at the beginning) or as a suffix (at the end) of the field name. |
|
|
The six types of new fields that you can create. |
|
string | Expression for calculating a new field value in a Derive node. |
|
string | |
|
string | |
|
string | |
|
string | |
|
string | Structured to supply the condition associated with a given value. |
|
string | Specifies the value for the new field when the On condition is met. |
|
string | Specifies the value for the new field when the Off condition is met. |
|
string | |
|
string | |
|
|
Assigns each record of the new field an initial value of or
. This value can change as each condition is met. |
|
string | |
|
string | |
|
string | |
|
string | |
|
string | |
|
string | |
|
string | |
|
|
This property can be used to define the measurement associated with the derived field. The
setter function can be passed either a string or one of the values. The
getter will always return on the values. |
|
|
For collection fields (lists with a depth of 0), this property defines the measurement type associated with the underlying values. |
|
|
For geospatial fields, this property defines the type of geospatial object represented by this field. This should be consistent with the list depth of the values |
|
boolean | For geospatial fields, this property defines whether this field has a coordinate system |
|
string | For geospatial fields, this property defines the coordinate system for this field |
Was the topic helpful?
0/1000