add-column
Description
add-column
adaptor can be used to create a new column at the end of a datatable.
By default, the cells on the newly added column will be empty, this can be changed by setting a value
. To move the new column to a different position in the datatable, use the select-columns
adaptor to reorder the columns.
To add different values to each row of the new column, use the map-column-values
adaptor.
Inputs
data
Type: datatable
Required: Yes
The datatable to which the new column will be added.
column name
Type: text
Required: Yes
The name of the new column to be added.
value
Type: text
Required: No
A value to be added to the column cells. If unspecified, empty values will be added.
Outputs
data
Type: datatable
A datatable with the new column added.
Examples
Example 1: Default behaviour.
Inputs:
data
Jan
1458
Feb
9874
column name
: Year
Outputs:
data
:
Jan
1458
Feb
9874
-> Added column Year
to the datatable with empty values.
Example 2: Add column with value
.
value
.Inputs:
data
:
Jan
1458
Feb
9874
column name
: Year
value
: 2024
Outputs:
data
:
Jan
1458
2024
Feb
9874
2024
-> Added column Year
to the datatable with the value 2024
.
Use Cases
Add a column for data sources to the datatables before merging to track data origin
Use Data-flo to create a spreadsheet including some existing data, as well as some standardised empty columns for users to fill in later.
When joining two datatables, and one is missing one column which is found in the second, this adaptor can be used to provide values for the missing column.
During data cleaning or transformation, users may need to transform the data in a way that requires the creation of a new column in order to retain the originally formatted data in the original column. This can include tasks like formatting dates, converting units, or categorizing data.
Last updated