bigframes.pandas.api.typing.StructAccessor.field#
- StructAccessor.field(name_or_index: str | int) Series[source]#
Extract a child field of a struct as a Series.
Examples:
>>> import bigframes.pandas as bpd >>> s = bpd.Series( ... [ ... {"version": 1, "project": "pandas"}, ... {"version": 2, "project": "pandas"}, ... {"version": 1, "project": "numpy"}, ... ], ... dtype=bpd.ArrowDtype(pa.struct( ... [("version", pa.int64()), ("project", pa.string())] ... )) ... )
Extract by field name.
>>> s.struct.field("project") 0 pandas 1 pandas 2 numpy Name: project, dtype: string
Extract by field index.
>>> s.struct.field(0) 0 1 1 2 2 1 Name: version, dtype: Int64
- Parameters:
name_or_index – Name (str) or index (int) of the child field to extract.
- Returns:
The data corresponding to the selected child field.
- Return type: