jorisvandenbossche commented on code in PR #44720:
URL: https://github.com/apache/arrow/pull/44720#discussion_r1842855604
##########
python/pyarrow/tests/test_pandas.py:
##########
@@ -4411,6 +4412,31 @@ def test_to_pandas_extension_dtypes_mapping():
assert isinstance(result['a'].dtype, pd.PeriodDtype)
+
+def test_to_pandas_extension_dtypes_mapping_complex_type():
+ pa_type = pa.struct(
+ [
+ pa.field("bar", pa.bool_(), nullable=False),
+ pa.field("baz", pa.float32(), nullable=True),
+ ],
+ )
+ pd_type = pd.ArrowDtype(pa_type)
+ schema = pa.schema([pa.field("foo", pa_type)])
+ df0 = pd.DataFrame(
+ [
+ {"foo": {"bar": True, "baz": np.float32(1)}},
+ {"foo": {"bar": True, "baz": None}},
+ ],
+ ).astype({"foo": pd_type})
+
+ # Round trip df0 into df1
+ with io.BytesIO() as stream:
+ df0.to_parquet(stream, schema=schema)
+ stream.seek(0)
+ df1 = pd.read_parquet(stream, dtype_backend="pyarrow")
Review Comment:
The metadata gets added on the pyarrow side, so `table = pa.table(df)` will
do that
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]