File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
third_party/bigframes_vendored/pandas/core/arrays/arrow Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1515from __future__ import annotations
1616
1717import bigframes_vendored .pandas .core .arrays .arrow .accessors as vendoracessors
18+ import pandas as pd
1819
1920from bigframes .core import log_adapter
2021import bigframes .dataframe
22+ import bigframes .dtypes
2123import bigframes .operations
2224import bigframes .operations .base
2325import bigframes .series
@@ -45,3 +47,13 @@ def explode(self) -> bigframes.dataframe.DataFrame:
4547 return bigframes .pandas .concat (
4648 [self .field (i ) for i in range (pa_type .num_fields )], axis = "columns"
4749 )
50+
51+ def dtypes (self ) -> pd .Series :
52+ pa_type = self ._dtype .pyarrow_dtype
53+ return pd .Series (
54+ data = [
55+ bigframes .dtypes .arrow_dtype_to_bigframes_dtype (pa_type .field (i ).type )
56+ for i in range (pa_type .num_fields )
57+ ],
58+ index = [pa_type .field (i ).name for i in range (pa_type .num_fields )],
59+ )
Original file line number Diff line number Diff line change @@ -92,3 +92,32 @@ def explode(self):
9292 The data corresponding to all child fields.
9393 """
9494 raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
95+
96+ def dtypes (self ):
97+ """
98+ Return the dtype object of each child field of the struct.
99+
100+ **Examples:**
101+
102+ >>> import bigframes.pandas as bpd
103+ >>> import pyarrow as pa
104+ >>> bpd.options.display.progress_bar = None
105+ >>> s = bpd.Series(
106+ ... [
107+ ... {"version": 1, "project": "pandas"},
108+ ... {"version": 2, "project": "pandas"},
109+ ... {"version": 1, "project": "numpy"},
110+ ... ],
111+ ... dtype=bpd.ArrowDtype(pa.struct(
112+ ... [("version", pa.int64()), ("project", pa.string())]
113+ ... ))
114+ ... )
115+ >>> s.struct.dtypes()
116+ version Int64
117+ project string[pyarrow]
118+ dtype: object
119+
120+ Returns:
121+ A *pandas* Series with the data type of all child fields.
122+ """
123+ raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
You can’t perform that action at this time.
0 commit comments