split-column
Description
split-column
adaptor splits values in a column into a number of columns using a specified separator to determine where to make each split.
Inputs
data
Type: datatable
Required: Yes
The datatable containing the column to be split.
column name
Type: text
Required: Yes
The name of the column to be split.
separator
Type: text
Required: Yes
The separator text, or regular expression, which denotes the points at which each split should occur. The separator is treated a regular expression if it begins and ends with /
.
new column names
Type: list
Required: Yes
The list of columns to be added.
include column
Type: boolean
Required: No
Specifies whether to include the original column in the output datatable. If unspecified, defaults to True
(original column will be included).
Outputs
data
Type: datatable
A datatable with new columns added.
Examples
Example 1: Default behaviour.
Inputs:
data:
id | code | name |
---|---|---|
1 | en-GB | United Kingdom |
2 | tr-TR | Turkey |
3 | en-US | United States |
4 | hi-IN | India |
column name:
code
separator:
-
new column names:
language
include column:
null(empty)
Outputs:
data
:
id | code | name | language |
---|---|---|---|
1 | en-GB | United Kingdom | en |
2 | tr-TR | Turkey | tr |
3 | en-US | United States | en |
4 | hi-IN | India | hi |
-> Created a new column language
with the values derived by splitting the values in code
column on -
separator. The original code column is included in the output by default.
Example 2: Exclude the original column in the output.
Inputs:
data:
id | code | name |
---|---|---|
1 | en-GB | United Kingdom |
2 | tr-TR | Turkey |
3 | en-US | United States |
4 | hi-IN | India |
column name:
code
separator:
-
new column names:
language
include column:
False
Outputs:
data
:
id | name | language |
---|---|---|
1 | United Kingdom | en |
2 | Turkey | tr |
3 | United States | en |
4 | India | hi |
-> Created a new column language
with the values derived by splitting the values in code
column on -
separator. The code column is included in the result by default.
Use Cases
Separate a date into components of year, month, and day.
Last updated