datascience.tables.Table.select¶
-
Table.
select
(*column_label_or_labels)[source]¶ Returns a new
Table
with only the columns incolumn_label_or_labels
.- Args:
column_label_or_labels
: Columns to select from theTable
as either column labels (str
) or column indices (int
).- Returns:
- An new instance of
Table
containing only selected columns. The columns of the newTable
are in the order given incolumn_label_or_labels
. - Raises:
KeyError
if any ofcolumn_label_or_labels
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