From b04a9cff1db4e9d66185e0000162ce3921c594dd Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Tue, 7 Mar 2023 19:25:51 +0100 Subject: [PATCH] Backport PR #51762: DOC: Add explanation how to convert arrow table to pandas df --- doc/source/user_guide/pyarrow.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/source/user_guide/pyarrow.rst b/doc/source/user_guide/pyarrow.rst index 94b2c724cd229..876ca9c164823 100644 --- a/doc/source/user_guide/pyarrow.rst +++ b/doc/source/user_guide/pyarrow.rst @@ -76,6 +76,18 @@ the pyarrow array constructor on the :class:`Series` or :class:`Index`. idx = pd.Index(ser) pa.array(idx) +To convert a :external+pyarrow:py:class:`pyarrow.Table` to a :class:`DataFrame`, you can call the +:external+pyarrow:py:meth:`pyarrow.Table.to_pandas` method with ``types_mapper=pd.ArrowDtype``. + +.. ipython:: python + + table = pa.table([pa.array([1, 2, 3], type=pa.int64())], names=["a"]) + + df = table.to_pandas(types_mapper=pd.ArrowDtype) + df + df.dtypes + + Operations ----------