[
https://issues.apache.org/jira/browse/ARROW-3654?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rok Mihevc updated ARROW-3654:
------------------------------
External issue URL: https://github.com/apache/arrow/issues/19960
> [Python] Column with CategoricalIndex fails to be read back
> -----------------------------------------------------------
>
> Key: ARROW-3654
> URL: https://issues.apache.org/jira/browse/ARROW-3654
> Project: Apache Arrow
> Issue Type: Bug
> Components: Python
> Affects Versions: 0.11.1
> Reporter: Armin Berres
> Priority: Major
> Labels: parquet
>
> When a column with a \{Categoricalndex} is written the data can never be read
> back.
> {code:python}
> df = pd.DataFrame([['a', 'b'], ['c', 'd']], columns=['c1', 'c2'])
> df['c1'] = df['c1'].astype('category')
> df = df.set_index(['c1'])
> table = pa.Table.from_pandas(df)
> pq.write_table(table, 'test.parquet')
> pq.read_pandas('test.parquet').to_pandas()
> {code}
> Results in
> {code}
> KeyError Traceback (most recent call last)
> ~/venv/mpptool/lib/python3.7/site-packages/pyarrow/pandas_compat.py in
> _pandas_type_to_numpy_type(pandas_type)
> 676 try:
> --> 677 return _pandas_logical_type_map[pandas_type]
> 678 except KeyError:
> KeyError: 'categorical'
> {code}
> The schema looks good:
> {code}
> column_indexes": [{"name": "c1", "field_name": "c1", "pandas_type":
> "categorical", "numpy_type": "int8", "metadata": {"num_categories": 2,
> "ordered": false}}]
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)