turicreate.SArray.dict_has_any_keys

SArray.dict_has_any_keys(keys)

Create a boolean SArray by checking the keys of an SArray of dictionaries. An element of the output SArray is True if the corresponding input element’s dictionary has any of the given keys. Fails on SArrays whose data type is not dict.

Parameters:
keys : list

A list of key values to check each dictionary against.

Returns:
out : SArray

A SArray of int type, where each element indicates whether the input SArray element contains any key in the input list.

Examples

>>> sa = turicreate.SArray([{"this":1, "is":5, "dog":7}, {"animal":1},
                         {"this": 2, "are": 1, "cat": 5}])
>>> sa.dict_has_any_keys(["is", "this", "are"])
dtype: int
Rows: 3
[1, 0, 1]