You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python] pa.Table.to_pandas(zero_copy_only=True) never succeeds #39194
Describe the bug, including details regarding any error messages, version, and platform.
When converting a Table to pandas, adding the zero_copy_only=True argument makes it always fail with ArrowInvalid.
In [17]: table=pa.table({'a': [1.0, 2.0, 3.0], 'b': ['x','y','z']})
In [19]: table.schemaOut[19]:
a: doubleb: stringIn [20]: table.to_pandas(zero_copy_only=True)
...
ArrowInvalid: Cannotdozerocopyconversionintomulti-columnDataFrameblock
Note that this is a similar bug report to #38644, but in that case the interaction with types_mapper is considered to be the reason for the Exception, whereas I found it is happening even without setting type mapping.
The keyword works fine for ChunkedArray conversions:
In [23]: table['a'].to_pandas(zero_copy_only=True)
Out[23]:
01.012.023.0Name: a, dtype: float64
even when adding type mapping to pandas Arrow types:
In [22]: table['a'].to_pandas(zero_copy_only=True, types_mapper=pd.ArrowDtype)
Out[22]:
01.012.023.0Name: a, dtype: double[pyarrow]
and fails on non-zero copy operations, like string to categorical conversion:
In [28]: table['b'].to_pandas(zero_copy_only=True, strings_to_categorical=True)
ArrowInvalid: Needtodictionaryencodeacolumn, butonlyzero-copyconversionsallowed
Is this expected behaviour? I.e., should the argument always flag Table -> DataFrame conversions as not being zero copy? In that case, it might make sense to remove the argument from pa.Table.to_pandas altogether, as it will always result in an exception thrown.
Component(s)
Python
Reacted by Mauricio Scheffer
Reacted by Andrew Crozier, Alex V. Kotlar and Yudhiesh Ravindranath
Root cause and fix: in the consolidated-block path (split_blocks=False), allow_zero_copy_blocks is never enabled in arrow_to_pandas.cc, so zero_copy_only=True always raises for Table/RecordBatch conversions, even for a single column. When zero_copy_only=True is requested, the columns can be converted as separate pandas blocks (per-column blocks can reference the original Arrow memory); conversions that genuinely need to copy still raise ArrowInvalid. Opened a PR: #55727 — verified locally with pyarrow 24.0.0 + pandas 3.0.2, regression tests included.
Activity
akotlar commentedon Apr 3, 2024
Running into the same issue
trendelkampschroer commentedon Jul 5, 2024
Same error here, for very simple types.
yudhiesh commentedon May 2, 2025
Still running into this issue on
v18.0.0gwerbin-tive commentedon Sep 15, 2025
I still have this problem with Pyarrow 21.0.0 and Pandas 2.3.2:
Reproduce with UV under
uv run, tested with UV 0.8.17.tigerlee commentedon Oct 17, 2025
Works with
tb.to_pandas(zero_copy_only=True, split_blocks=True, types_mapper=pd.ArrowDtype)sameer727 commentedon Nov 22, 2026
Root cause and fix: in the consolidated-block path (
split_blocks=False),allow_zero_copy_blocksis never enabled inarrow_to_pandas.cc, sozero_copy_only=Truealways raises for Table/RecordBatch conversions, even for a single column. Whenzero_copy_only=Trueis requested, the columns can be converted as separate pandas blocks (per-column blocks can reference the original Arrow memory); conversions that genuinely need to copy still raiseArrowInvalid. Opened a PR: #55727 — verified locally with pyarrow 24.0.0 + pandas 3.0.2, regression tests included.