apache / apache/arrow

[Python][C++] Casting nested list array with null structs results in invalid array

Open
#44,881 2 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.

The code below produces an ArrowIndexError when attempting to convert a PyArrow Table with nested null values into a Pandas DataFram. Everything works fine if i use `to_pydict` instead.

```py
import pyarrow as pa
import pandas as pd
import json

json_data = json.loads("""
[
{
"key1": [
{
"key2": null
},
{
"key2": null
}
]
}
]
""")

pa_table = pa.Table.from_pylist(json_data)
my_dict = pa_table.to_pydict() # This works as expected: {'key1': [[{'key2': None}, {'key2': None}]]}
df = pa_table.to_pandas(types_mapper=pd.ArrowDtype).to_dict()
```

I'm using pyarrow 17 (pandas 2.2.3)

### Component(s)

Python

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.