turicreate.SArray.filter_by

SArray.filter_by(values, exclude=False)

Filter an SArray by values inside an iterable object. The result is an SArray that only includes (or excludes) the values in the given values SArray. If values is not an SArray, we attempt to convert it to one before filtering.

Parameters:
values : SArray | list | numpy.ndarray | pandas.Series | str
The values to use to filter the SArray. The resulting SArray will
only include rows that have one of these values in the given
column.
exclude : bool
If True, the result SArray will contain all rows EXCEPT those that
have one of the ``values``.
Returns:
out : SArray
The filtered SArray.

Examples

>>> sa = SArray(['dog', 'cat', 'cow', 'horse'])
>>> sa.filter_by(['cat', 'hamster', 'dog', 'fish', 'bird', 'snake'])
dtype: str
Rows: 2
['dog', 'cat']
>>> sa.filter_by(['cat', 'hamster', 'dog', 'fish', 'bird', 'snake'], exclude=True)
dtype: str
Rows: 2
['horse', 'cow']