prefix function in the Factory

The prefix function considers the chosen value as prefix and returns the subsequent characters.


Parameters

prefix(column, value, last)

If you are using continuous attributes, check the Flow Execution Parameters.

Parameter

Description

column

The nominal attribute containing the strings. If it is not nominal, it will be casted to nominal upon function’s computation. The column parameter is mandatory.

value

The substring value to be searched into the strings of the column. The value parameter is mandatory.

The value parameter is case sensitive.

last

If False, or not specified, the function selects the first occurrence of the value within the string, while if it is True, the function selects the last occurrence of the value which has to be considered.


Example

The following example uses the Adult dataset.

Description

Screenshot

In this example, we want to retrieve as prefixes the characters before the i in the marital-status attribute.

Add a new attribute, called prefix, and type the following formula:

prefix($"marital-status",'i',true)

As we have specified True in the last parameter, the function will consider the last occurrence of the value: as we can see in row 2, Married-civ-spouse becomes Married-c, as the function considers the last occurrence of the value.