Skip to main content

DB_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

Returns 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 a By_Type selector to choose columns by type. Note: specifying columns by type ignores size and precision.
  • error_on_missing_columns: Specifies if a missing input column should result in an error regardless of the on_problems settings. Defaults to False.
  • on_problems: Specifies how to handle problems if they occur, reporting them as warnings by default.

Examples

Remove columns with given names.

      table.remove_columns ["bar", "foo"]

Remove columns using names passed as a Vector.

      table.remove_columns ["bar", "foo"]

Remove columns matching a regular expression.

      table.remove_columns "foo.+".to_regex Case_Sensitivity.Insensitive

Remove the first two columns and the last column.

      table.remove_columns [-1, 0, 1]

Remove integer columns.

      table.remove_columns [..By_Type ..Integer]

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, a Missing_Input_Columns is reported according to the on_problems setting, unless error_on_missing_columns is set to True, in which case it is raised as an error.