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 theTableas either column labels (str) or column indices (int).- Returns:
A new instance of
Tablecontaining only selected columns. The columns of the newTableare in the order given incolumn_or_columns.- Raises:
KeyErrorif any ofcolumn_or_columnsare 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