turicreate.SArray.dict_trim_by_values¶
-
SArray.
dict_trim_by_values
(lower=None, upper=None)¶ Filter dictionary values to a given range (inclusive). Trimming is only performed on values which can be compared to the bound values. Fails on SArrays whose data type is not
dict
.Parameters: - lower : int or long or float, optional
The lowest dictionary value that would be retained in the result. If not given, lower bound is not applied.
- upper : int or long or float, optional
The highest dictionary value that would be retained in the result. If not given, upper bound is not applied.
Returns: - out : SArray
An SArray of dictionary type, with each dict element trimmed according to the input criteria.
See also
Examples
>>> sa = turicreate.SArray([{"this":1, "is":5, "dog":7}, {"this": 2, "are": 1, "cat": 5}]) >>> sa.dict_trim_by_values(2,5) dtype: dict Rows: 2 [{'is': 5}, {'this': 2, 'cat': 5}]
>>> sa.dict_trim_by_values(upper=5) dtype: dict Rows: 2 [{'this': 1, 'is': 5}, {'this': 2, 'are': 1, 'cat': 5}]