bigframes.bigquery.struct#

bigframes.bigquery.struct(value: dataframe.DataFrame) series.Series[source]#

Takes a DataFrame and converts it into a Series of structs with each struct entry corresponding to a DataFrame row and each struct field corresponding to a DataFrame column

Examples:

>>> import bigframes.pandas as bpd
>>> import bigframes.bigquery as bbq
>>> import bigframes.series as series
>>> srs = series.Series([{"version": 1, "project": "pandas"}, {"version": 2, "project": "numpy"},])
>>> df = srs.struct.explode()
>>> bbq.struct(df)
0    {'project': 'pandas', 'version': 1}
1     {'project': 'numpy', 'version': 2}
dtype: struct<project: string, version: int64>[pyarrow]
Args:
value (bigframes.dataframe.DataFrame):

The DataFrame to be converted to a Series of structs

Returns:

bigframes.series.Series: A new Series with struct entries representing rows of the original DataFrame