turicreate.SArray.dict_has_all_keys

SArray.dict_has_all_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 all 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 all keys in the input list.

Examples

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