hipdf.core.column.lists.ListMethods.get#
21 min read time
Applies to Linux
- ListMethods.get(index: int, default: Any | None = None) Series | GenericIndex#
Extract element at the given index from each list in a Series of lists.
indexcan be an integer or a sequence of integers. Ifindexis an integer, the element at positionindexis extracted from each list. Ifindexis a sequence, it must be of the same length as the Series, andindex[i]specifies the position of the element to extract from thei-th list in the Series.If the index is out of bounds for any list, return <NA> or, if provided,
default. Thus, this method never raises anIndexError.Parameters#
index : int or sequence of ints default : scalar, optional
Returns#
Series or Index
Examples#
>>> s = cudf.Series([[1, 2, 3], [3, 4, 5], [4, 5, 6]]) >>> s.list.get(-1) 0 3 1 5 2 6 dtype: int64
>>> s = cudf.Series([[1, 2], [3, 4, 5], [4, 5, 6]]) >>> s.list.get(2) 0 <NA> 1 5 2 6 dtype: int64
>>> s.list.get(2, default=0) 0 0 1 5 2 6 dtype: int64
>>> s.list.get([0, 1, 2]) 0 1 1 4 2 6 dtype: int64