DB_Table.reorder_columns
reorder_columnscolumns positioncase_sensitivityerror_on_missing_columnson_problems
Group: Selections
Documentation
Returns a new table with the specified selection of columns moved to either the start or the end in the specified order.
Arguments
columns
: Specifies columns by a name, type, index or regular expression to match names, or a Vector of these.position
: Specifies how to place the selected columns in relation to the remaining columns which were not matched bycolumns
(if any).case_sensitivity
: Controls whether to be case sensitive when matching column names.error_on_missing_columns
: Specifies if a missing input column should result in an error regardless of theon_problems
settings. Defaults toFalse
.on_problems
: Specifies how to handle problems if they occur, reporting them as warnings by default.
Examples
Move a column with a specified name to back.
table.reorder_columns ["foo"] position=Position.After_Other_Columns
Move columns using names passed as a Vector.
table.reorder_columns ["bar", "foo"] position=Position.After_Other_Columns
Move columns matching a regular expression to front, keeping columns matching "foo.+" before columns matching "b.*".
table.reorder_columns "foo.+".to_regex case_sensitivity=Case_Sensitivity.Insensitive
Swap the first two columns.
table.reorder_columns [1, 0]
Move the first column to back.
table.reorder_columns [0] position=Position.After_Other_Columns
Errors
- If a column in
columns
is not in the input table, aMissing_Input_Columns
is reported according to theon_problems
setting, unlesserror_on_missing_columns
is set toTrue
, in which case it is raised as an error.