rename-columns

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 columns.

Arguments

Inputs:

data: The datatable containing columns to be renamed.

mapping: The mapping of old column names (keys) to new ones (values)

discard: (discard unmapped) Specifies whether to discard columns which are not mapped in column names. If unspecified, defaults to "False" (unmapped columns are kept).

Output:

data: A datatable with the columns renamed.

Example

Possible use cases

  • 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.

Last updated