You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Sutou Kouhei (JIRA)" <ji...@apache.org> on 2019/06/27 06:40:00 UTC
[jira] [Resolved] (ARROW-3654) [Python] Column with
CategoricalIndex fails to be read back
[ https://issues.apache.org/jira/browse/ARROW-3654?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sutou Kouhei resolved ARROW-3654.
---------------------------------
Resolution: Cannot Reproduce
> [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
(v7.6.3#76005)