cudf.core.column.lists.ListMethods.index#
- ListMethods.index(search_key: ScalarLike | ColumnLike) ParentType [source]#
Returns integers representing the index of the search key for each row.
If
search_key
is a sequence, it must be the same length as the Series andsearch_key[i]
represents the search key for thei
-th row of the Series.If the search key is not contained in a row, -1 is returned. If either the row or the search key are null, <NA> is returned. If the search key is contained multiple times, the smallest matching index is returned.
- Parameters:
- search_keyscalar or sequence of scalars
Element or elements being searched for in each row of the list column
- Returns:
- Series or Index
Examples
>>> s = cudf.Series([[1, 2, 3], [3, 4, 5], [4, 5, 6]]) >>> s.list.index(4) 0 -1 1 1 2 0 dtype: int32
>>> s = cudf.Series([["a", "b", "c"], ["x", "y", "z"]]) >>> s.list.index(["b", "z"]) 0 1 1 2 dtype: int32
>>> s = cudf.Series([[4, 5, 6], None, [-3, -2, -1]]) >>> s.list.index([None, 3, -2]) 0 <NA> 1 <NA> 2 1 dtype: int32