apache / apache/arrow

[Python] Conversion of pyArrow table to pandas fails with error: ArrowException: Unknown error: Wrapping Q� failed

Open
#34,239 4 comments 0 reactions 0 assignees View on GitHub
Component: Python Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the bug, including details regarding any error messages, version, and platform.

Using `pyArrow` `11.0.0`.
Python 3.10

I used ArrowFlight to download the csv data: [titanic_pyarrow_issue.csv](https://github.com/apache/arrow/files/10768333/titanic_pyarrow_issue.csv). I saved the batches to pyarrow.Table and then tried to convert the Table to pandas:
```
info = readClient.get_flight_info( flight.FlightDescriptor.for_command(source_command))
for endpoint in info.endpoints:
reader = readClient.do_get(endpoint.ticket)
df, metadata = reader.read_chunk()
data_table = pa.Table.from_batches(batches=[df]
data = data_table.to_pandas() # the line fails
# df = reader.read_pandas() # it also fails
```

The conversion to pandas type has failed with the following error:
```
File "/Users/[...]/python/flightdemo.py", line 71, in
data = data_table.to_pandas()
File "pyarrow/array.pxi", line 830, in pyarrow.lib._PandasConvertible.to_pandas
File "pyarrow/table.pxi", line 3990, in pyarrow.lib.Table._to_pandas
File "/Users/[...]/lib/python3.9/site-packages/pyarrow/pandas_compat.py", line 820, in table_to_blockmanager
blocks = _table_to_blocks(options, table, categories, ext_columns_dtypes)
File "/Users/[...]/lib/python3.9/site-packages/pyarrow/pandas_compat.py", line 1169, in _table_to_blocks
result = pa.lib.table_to_blocks(options, block_table, categories,
File "pyarrow/table.pxi", line 2646, in pyarrow.lib.table_to_blocks
File "pyarrow/error.pxi", line 138, in pyarrow.lib.check_status
pyarrow.lib.ArrowException: Unknown error: Wrapping Q� failed
```

Here is pickled `data_table` object:
[data_unexpected_file.pickle.zip](https://github.com/apache/arrow/files/10768406/data_unexpected_file.pickle.zip)

_To read the pickle file:_
_1. unzip_
_2. use pickle.load:_
```
with open("data_unexpected_file.pickle", 'rb') as f:
loaded_table = pickle.load(f)
```

It's worth to mention that `pandas` can read the csv file without any errors.

### Component(s)

Python

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure using the attached CSV or data_unexpected_file.pickle, then follow the conversion from flightdemo.py line 71 through Table.to_pandas() and pandas_compat.py. Compare to reader.read_pandas() and verify that the provided table converts without the ArrowException; the issue does not identify a specific fix or test file.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.