class_docstr: List methods for Series
class_docstr_tok: ["List","methods","for","Series"]
docstr: Extract element at the given index from each list in a Series of lists.
  
  ``index`` can be an integer or a sequence of integers.  If
  ``index`` is an integer, the element at position ``index`` is
  extracted from each list.  If ``index`` is a sequence, it must
  be of the same length as the Series, and ``index[i]``
  specifies the position of the element to extract from the
  ``i``-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 an
  ``IndexError``.
  
  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
docstr_tok: ["Extract","element","at","the","given","index","from","each","list","in","a","Series","of","lists",".","``","index","``","can","be","an","integer","or","a","sequence","of","integers",".","If","``","index","``","is","an","integer",",","the","element","at","position","``","index","``","is","extracted","from","each","list",".","If","``","index","``","is","a","sequence",",","it","must","be","of","the","same","length","as","the","Series",",","and","``","index","[","i","]","``","specifies","the","position","of","the","element","to","extract","from","the","``","i","``","-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","an","``","IndexError","``",".","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"]
code: def get(
      self,
      index: int,
      default: Optional[Union[ScalarLike, ColumnLike]] = None,
  ) -> ParentType:
      """
      Extract element at the given index from each list in a Series of lists.
  
      ``index`` can be an integer or a sequence of integers.  If
      ``index`` is an integer, the element at position ``index`` is
      extracted from each list.  If ``index`` is a sequence, it must
      be of the same length as the Series, and ``index[i]``
      specifies the position of the element to extract from the
      ``i``-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 an
      ``IndexError``.
  
      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
      """
      if is_scalar(index):
          out = extract_element_scalar(self._column, cudf.Scalar(index))
      else:
          index = as_column(index)
          out = extract_element_column(self._column, as_column(index))
  
      if not (default is None or default is NA):
          # determine rows for which `index` is out-of-bounds
          lengths = count_elements(self._column)
          out_of_bounds_mask = (np.negative(index) > lengths) | (
              index >= lengths
          )
  
          # replace the value in those rows (should be NA) with `default`
          if out_of_bounds_mask.any():
              out = out._scatter_by_column(
                  out_of_bounds_mask, cudf.Scalar(default)
              )
      if out.dtype != self._column.dtype.element_type:
          # libcudf doesn't maintain struct labels so we must transfer over
          # manually from the input column if we lost some information
          # somewhere. Not doing this unilaterally since the cost is
          # non-zero..
          out = out._with_type_metadata(self._column.dtype.element_type)
      return self._return_or_inplace(out)
  
imports: from __future__ import annotations
  from functools import cached_property
  from typing import List, Optional, Sequence, Tuple, Union
  import numpy
  import pyarrow
  from typing_extensions import Self
  import cudf
  from cudf._lib.copying import segmented_gather
  from cudf._lib.lists import concatenate_list_elements, concatenate_rows, contains_scalar, count_elements, distinct, extract_element_column, extract_element_scalar, index_of_column, index_of_scalar, sort_lists
  from cudf._lib.strings.convert.convert_lists import format_list_column
  from cudf._lib.types import size_type_dtype
  from cudf._typing import ColumnBinaryOperand, ColumnLike, Dtype, ScalarLike
  from cudf.api.types import _is_non_decimal_numeric_dtype, is_scalar
  from cudf.core.column import ColumnBase, as_column, column
  from cudf.core.column.methods import ColumnMethods, ParentType
  from cudf.core.dtypes import ListDtype
  from cudf.core.missing import NA
label_desc: Use image node_id 2 for calling the ListMethods obj's underlying member method code with example usage: obj.get(index, default) and returns: self