turicreate.SArray.element_slice — Turi Create API 6.4.1 documentation (original) (raw)
SArray.
element_slice
(start=None, stop=None, step=None)¶
This returns an SArray with each element sliced accordingly to the slice specified. This is conceptually equivalent to:
g.apply(lambda x: x[start🪜stop])
The SArray must be of type list, vector, or string.
For instance:
g = SArray(["abcdef","qwerty"]) g.element_slice(start=0, stop=2) dtype: str Rows: 2 ["ab", "qw"] g.element_slice(3,-1) dtype: str Rows: 2 ["de", "rt"] g.element_slice(3) dtype: str Rows: 2 ["def", "rty"]
g = SArray([[1,2,3], [4,5,6]]) g.element_slice(0, 1) dtype: str Rows: 2 [[1], [4]]
Parameters: | start : int or None (default) The start position of the slice stop: int or None (default) The stop position of the slice step: int or None (default) The step size of the slice |
---|---|
Returns: | out : SArray Each individual vector/string/list sliced according to the arguments. |