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    {'version': 1, 'project': 'pandas'}
1     {'version': 2, 'project': 'numpy'}
dtype: struct<version: int64, project: string>[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