[ 
https://issues.apache.org/jira/browse/ARROW-3654?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16831599#comment-16831599
 ] 

Joris Van den Bossche commented on ARROW-3654:
----------------------------------------------

[~aberres] I cannot reproduce this with pyarrow 0.13 and pandas 0.24.2:

 
{code:java}
In [4]: 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()                              
                                                                              
Out[4]: 
   c2
c1   
a   b
c   d

In [5]: pa.__version__                                                          
                                                                              
Out[5]: '0.13.0'

In [6]: pd.__version__                                                          
                                                                              
Out[6]: '0.25.0.dev0+452.g331516126'
{code}
 

Can you still reproduce this? Or what version were you using?

> [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)

Reply via email to