Table.remove_columns
remove_columnscolumns case_sensitivityerror_on_missing_columnson_problems
Group: Selections
Aliases: drop fields
, drop_columns
, remove fields
, select columns
, select fields
Documentation
Creates a new table with the chosen set of columns, as specified by the columns
, removed from the input table. Any unmatched input columns will be kept in the output. Columns are returned in the same order as in the input.
Arguments
columns
: Specifies columns by a single instance or Vector of names; indexes or regular expressions to match names; or aBy_Type
selector to choose columns by type.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.
Returns
- A new table with the chosen subset of columns removed.
Examples
Remove columns by name.
table = Table.from_rows ["bar","foo","buzz","bizz"] [["John", "25","abc","123"]]
output = table.remove_columns ["bar", "foo"]
Returns a Table
buzz | bizz |
---|---|
abc | 123 |
Remove columns matching a regular expression.
table = Table.from_rows ["bar","foo","buzz","bizz"] [["John", "25","abc","123"]]
output = table.remove_columns [regex "b.+"]
Returns a Table
foo |
---|
25 |
Remove the first two columns and the last column
table = Table.from_rows ["bar","foo","buzz","bizz"] [["John", 25,"abc",123]]
output = table.select_columns [-1, 0, 1]
Returns a Table
buzz |
---|
abc |
Remove integer columns.
table = Table.from_rows ["bar","foo","buzz","bizz"] [["John", 25,"abc",123]]
output = table.remove_columns [..By_Type ..Integer]
Returns a Table
bar | buzz |
---|---|
John | abc |
Errors
- If there are no columns in the output table, a
No_Output_Columns
is raised as an error regardless of the problem behavior, because it is not possible to create a table without any columns. - 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.
Remarks
Selecting By Type
If selecting by type, then the length, scale and precision are ignored.
In other words, ..Text
will match any text column, regardless of its
length or being fixed or variable length. Similarly, ..Integer
will
match any integer column, regardless of its size.