datascience.tables.Table.select¶
-
Table.select(*column_label_or_labels)[source]¶ Returns a new
Tablewith only the columns incolumn_label_or_labels.- Args:
column_label_or_labels: Columns to select from theTableas either column labels (str) or column indices (int).- Returns:
- An new instance of
Tablecontaining only selected columns. The columns of the newTableare in the order given incolumn_label_or_labels. - Raises:
KeyErrorif any ofcolumn_label_or_labelsare 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