concatenate-columns
Description
concatenate-columns
adaptor concatenates values from two or more columns into a single value, with or without a delimiter between them.
The order given in the columns
input is the order in which the values are concatenated. By default, the values will be concatenated without a delimiter between them, this can be changed by setting the separator value.
Inputs
data
Type: datatable
Required: Yes
The datatable containing the columns to be concatenated.
columns
Type: list
Required: Yes
A list of columns to be concatenated. The output value matches the listed order.
separator
Type: text
Required: No
Specifies text to separate each concatenated value. Defaults to ""
(blank).
concatenated column
Type: text
Required: Yes
The new column containing concatenated values.
Outputs
data
Type: datatable
A datatable with the concatenated column added.
Examples
Example 1: Default behaviour.
Inputs:
data
:
Sample ID | A | B | C |
---|---|---|---|
Sample A | R | R | R |
Sample B | S | R | S |
Sample C | R | S | I |
Sample D | I | R | R |
Sample E | R | r | R |
Sample F | r | r | r |
columns
:
A
B
C
concatenated column
: Result
Outputs:
data
:
Sample ID | A | B | C | Result |
---|---|---|---|---|
Sample A | R | R | R | RRR |
Sample B | S | R | S | SRS |
Sample C | R | S | I | RSI |
Sample D | I | R | R | IRR |
Sample E | R | r | R | RrR |
Sample F | r | r | r | rrr |
-> Concatenated the columns A
, B
and C
and added the value to the Result
column.
Example 2: Concatenation with a separator.
Inputs:
data
:
Sample ID | A | B | C |
---|---|---|---|
Sample A | R | R | R |
Sample B | S | R | S |
Sample C | R | S | I |
Sample D | I | R | R |
Sample E | R | r | R |
Sample F | r | r | r |
columns
:
A
B
C
concatenated column
: Result
separator
: ;
Outputs:
data
:
Sample ID | A | B | C | Result |
---|---|---|---|---|
Sample A | R | R | R | R;R;R |
Sample B | S | R | S | S;R;S |
Sample C | R | S | I | R;S;I |
Sample D | I | R | R | I;R;R |
Sample E | R | r | R | R;r;R |
Sample F | r | r | r | r;r;r |
-> Concatenated the columns A
, B
and C
and added the value to the Result
column with a ;
separator.
Use Cases
Use this adaptor to generate a composite key or ID by concatenating multiple column values
Combining values from different categorical columns can result in a new categorical variable. This can be useful when you want to create a combined label that captures the essence of the data more effectively.
Concatenating year, month, and day values from separate columns into a new date column
When working with data that includes components of URLs or file paths, concatenation can be used to construct these addresses in a new column. This is particularly useful when you need to reference external resources or link to specific locations.
Concatenating values allows for the creation of a new column with a specific format suitable for display or visualisation labeling purposes.
Last updated