You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "GianlucaFicarelli (via GitHub)" <gi...@apache.org> on 2023/06/05 09:42:48 UTC
[GitHub] [arrow] GianlucaFicarelli commented on issue #33030: pyarrow fails to write and read a dataframe with MultiIndex containing a RangeIndex with Pandas 1.5.0
GianlucaFicarelli commented on issue #33030:
URL: https://github.com/apache/arrow/issues/33030#issuecomment-1576471014
This issue is still happening when using:
- pyarrow 12.0.0
- pandas 2.0.2
Steps to reproduce (similar to the ones in the original description):
```python
import pandas as pd
df1 = pd.DataFrame({"a": [10, 11, 12], "b": [20, 21, 22]}, index=pd.RangeIndex(3, name="range0"))
df1 = df1.set_index("b", append=True)
print(df1)
path = "example.parquet"
df1.to_parquet(path, engine="pyarrow", index=None)
pd.read_parquet(path, engine="pyarrow")
```
Error:
```
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "./venv/lib/python3.10/site-packages/pandas/io/parquet.py", line 509, in read_parquet
return impl.read(
File "./venv/lib/python3.10/site-packages/pandas/io/parquet.py", line 230, in read
result = pa_table.to_pandas(**to_pandas_kwargs)
File "pyarrow/array.pxi", line 837, in pyarrow.lib._PandasConvertible.to_pandas
File "pyarrow/table.pxi", line 4114, in pyarrow.lib.Table._to_pandas
File "./venv/lib/python3.10/site-packages/pyarrow/pandas_compat.py", line 810, in table_to_blockmanager
table, index = _reconstruct_index(table, index_descriptors,
File "./venv/lib/python3.10/site-packages/pyarrow/pandas_compat.py", line 961, in _reconstruct_index
result_table, index_level, index_name = _extract_index_level(
File "./venv/lib/python3.10/site-packages/pyarrow/pandas_compat.py", line 999, in _extract_index_level
logical_name = field_name_to_metadata[field_name]['name']
KeyError: 'b'
```
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org