rename-columns adaptor renames existing columns in a datatable.
Maps old (existing) column names to new column names, with the option to discard columns that are not listed in the mapping.
Note that this does not create a second copy of mapped columns with a new name, it simply changes the name of the mapped column.
data
Type: datatable
Required: Yes
The datatable containing columns to be renamed.
column names
Type: dictionary
Required: Yes
The mapping of old column names to new ones.
discard unmapped
Type: boolean
Required: No
Specifies whether to discard columns which are not mapped in column names. If unspecified, defaults to False (unmapped columns are kept).
data
Type: datatable
A datatable with the columns renamed.
Example 1: Default behaviour.
data:
column names:
discard unmapped: null (empty)
data:
id
country code
country name
-> Renamed the columns code and name to country code and country name respectively.
Example 2: Discard unmapped columns.
data:
column names:
discard unmapped: True
data:
-> Renamed the mapped columns and discared the unmapped column id.
Preparing datatables for merging by ensuring that the same name is used for the same column in both datasets.
Creating user-friendly column display names before exporting data to a Microreact project or an external report.
Making column names more descriptive to ensure proper interpretation.