datascience.tables.Table.select

Table.select(*column_or_columns)[source]

Return a table with only the columns in column_or_columns.

Args:
column_or_columns: Columns to select from the Table as either column labels (str) or column indices (int).
Returns:
A new instance of Table containing only selected columns. The columns of the new Table are in the order given in column_or_columns.
Raises:
KeyError if any of column_or_columns are not in the table.
>>> flowers = Table().with_columns(
...     'Number of petals', make_array(8, 34, 5),
...     'Name', make_array('lotus', 'sunflower', 'rose'),
...     'Weight', make_array(10, 5, 6)
... )
>>> flowers
Number of petals | Name      | Weight
8                | lotus     | 10
34               | sunflower | 5
5                | rose      | 6
>>> flowers.select('Number of petals', 'Weight')
Number of petals | Weight
8                | 10
34               | 5
5                | 6
>>> flowers  # original table unchanged
Number of petals | Name      | Weight
8                | lotus     | 10
34               | sunflower | 5
5                | rose      | 6
>>> flowers.select(0, 2)
Number of petals | Weight
8                | 10
34               | 5
5                | 6