datascience.tables.Table.where¶
-
Table.
where
(column_or_label, value=None)[source]¶ Return a Table of rows for which the column is
value
or a non-zero value.If
column_or_label
contains Boolean values, returns rows corresponding to True.- Args:
column_or_label
: The header name of a column in the table or an array.value
: Value for comparison with items incolumn_or_label
.- Returns:
- An instance of
Table
containing rows for which thecolumn_or_label
column orcolumn_or_label
itself is non-zero or True, or is equal tovalue
, if provided.
>>> marbles = Table().with_columns([ ... "Color", ["Red", "Green", "Blue", "Red", "Green", "Green"], ... "Shape", ["Round", "Rectangular", "Rectangular", "Round", "Rectangular", "Round"], ... "Amount", [4, 6, 12, 7, 9, 2], ... "Price", [1.30, 1.20, 2.00, 1.75, 1.40, 1.00]]) >>> marbles Color | Shape | Amount | Price Red | Round | 4 | 1.3 Green | Rectangular | 6 | 1.2 Blue | Rectangular | 12 | 2 Red | Round | 7 | 1.75 Green | Rectangular | 9 | 1.4 Green | Round | 2 | 1 >>> marbles.where("Shape", "Round") Color | Shape | Amount | Price Red | Round | 4 | 1.3 Red | Round | 7 | 1.75 Green | Round | 2 | 1 >>> marbles.where(marbles.column("Shape") == "Round") # equivalent to the previous example Color | Shape | Amount | Price Red | Round | 4 | 1.3 Red | Round | 7 | 1.75 Green | Round | 2 | 1 >>> marbles.where(marbles.column("Price") > 1.5) Color | Shape | Amount | Price Blue | Rectangular | 12 | 2 Red | Round | 7 | 1.75