0 / 0
derivenode properties

derivenode properties

Derive node iconThe 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 XPos and YPos 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:

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")
Table 1. derivenode properties
derivenode properties Data type Property description
new_name string Name of new field.
mode Single Multiple Specifies single or multiple fields.
fields list Used in Multiple mode only to select multiple fields.
name_extension string Specifies the extension for the new field name(s).
add_as Suffix Prefix Adds the extension as a prefix (at the beginning) or as a suffix (at the end) of the field name.
result_type Formula Flag Set State Count Conditional The six types of new fields that you can create.
formula_expr string Expression for calculating a new field value in a Derive node.
flag_expr string  
flag_true string  
flag_false string  
set_default string  
set_value_cond string Structured to supply the condition associated with a given value.
state_on_val string Specifies the value for the new field when the On condition is met.
state_off_val string Specifies the value for the new field when the Off condition is met.
state_on_expression string  
state_off_expression string  
state_initial On Off Assigns each record of the new field an initial value of On or Off. This value can change as each condition is met.
count_initial_val string  
count_inc_condition string  
count_inc_expression string  
count_reset_condition string  
cond_if_cond string  
cond_then_expr string  
cond_else_expr string  
formula_measure_type Range / MeasureType.RANGE Discrete / MeasureType.DISCRETE Flag / MeasureType.FLAG Set / MeasureType.SET OrderedSet / MeasureType.ORDERED_SET Typeless / MeasureType.TYPELESS Collection / MeasureType.COLLECTION Geospatial / MeasureType.GEOSPATIAL 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 MeasureType values. The getter will always return on the MeasureType values.
collection_measure Range / MeasureType.RANGE Flag / MeasureType.FLAG Set / MeasureType.SET OrderedSet / MeasureType.ORDERED_SET Typeless / MeasureType.TYPELESS For collection fields (lists with a depth of 0), this property defines the measurement type associated with the underlying values.
geo_type Point MultiPoint LineString MultiLineString Polygon MultiPolygon 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
has_coordinate_system boolean For geospatial fields, this property defines whether this field has a coordinate system
coordinate_system string For geospatial fields, this property defines the coordinate system for this field
Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more