class_docstr: Struct methods for Series
class_docstr_tok: ["Struct","methods","for","Series"]
docstr: Extract children of the specified struct column
  in the Series
  
  Parameters
  ----------
  key: int or str
      index/position or field name of the respective
      struct column
  
  Returns
  -------
  Series
  
  Examples
  --------
  >>> s = cudf.Series([{'a': 1, 'b': 2}, {'a': 3, 'b': 4}])
  >>> s.struct.field(0)
  0    1
  1    3
  dtype: int64
  >>> s.struct.field('a')
  0    1
  1    3
  dtype: int64
docstr_tok: ["Extract","children","of","the","specified","struct","column","in","the","Series","Parameters","--","--","--","--","--","key",":","int","or","str","index\/position","or","field","name","of","the","respective","struct","column","Returns","--","--","--","-","Series","Examples","--","--","--","--",">",">",">","s","=","cudf.Series","(","[","{","'","a","'",":","1",",","'","b","'",":","2","}",",","{","'","a","'",":","3",",","'","b","'",":","4","}","]",")",">",">",">","s.struct.field","(","0",")","0","1","1","3","dtype",":","int64",">",">",">","s.struct.field","(","'","a","'",")","0","1","1","3","dtype",":","int64"]
code: def field(self, key):
      """
      Extract children of the specified struct column
      in the Series
  
      Parameters
      ----------
      key: int or str
          index/position or field name of the respective
          struct column
  
      Returns
      -------
      Series
  
      Examples
      --------
      >>> s = cudf.Series([{'a': 1, 'b': 2}, {'a': 3, 'b': 4}])
      >>> s.struct.field(0)
      0    1
      1    3
      dtype: int64
      >>> s.struct.field('a')
      0    1
      1    3
      dtype: int64
      """
      fields = list(self._column.dtype.fields.keys())
      if key in fields:
          pos = fields.index(key)
          return self._return_or_inplace(self._column.children[pos])
      else:
          if isinstance(key, int):
              try:
                  return self._return_or_inplace(
                      self._column.children[key]
                  )
              except IndexError:
                  raise IndexError(f"Index {key} out of range")
          else:
              raise KeyError(
                  f"Field '{key}' is not found in the set of existing keys."
              )
  
imports: from __future__ import annotations
  from functools import cached_property
  from typing import Optional
  import pandas
  import pyarrow
  import cudf
  from cudf._typing import Dtype
  from cudf.core.column import ColumnBase, build_struct_column
  from cudf.core.column.methods import ColumnMethods
  from cudf.core.dtypes import StructDtype
  from cudf.core.missing import NA
label_desc: Use image node_id 2 for calling the StructMethods obj's underlying member method code with example usage: obj.field(key) and returns: self, self