turicreate.SArray.dict_trim_by_keys¶
-
SArray.
dict_trim_by_keys
(keys, exclude=True)¶ Filter an SArray of dictionary type by the given keys. By default, all keys that are in the provided list in
keys
are excluded from the returned SArray.Parameters: - keys : list
A collection of keys to trim down the elements in the SArray.
- exclude : bool, optional
If True, all keys that are in the input key list are removed. If False, only keys that are in the input key list are retained.
Returns: - out : SArray
A SArray of dictionary type, with each dictionary element trimmed according to the input criteria.
See also
Examples
>>> sa = turicreate.SArray([{"this":1, "is":1, "dog":2}, {"this": 2, "are": 2, "cat": 1}]) >>> sa.dict_trim_by_keys(["this", "is", "and", "are"], exclude=True) dtype: dict Rows: 2 [{'dog': 2}, {'cat': 1}]