[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jira] [Created] (ARROW-3652) [Python] CategoricalIndex is lost after reading back

Armin Berres created ARROW-3652:

             Summary: [Python] CategoricalIndex is lost after reading back
                 Key: ARROW-3652
                 URL: https://issues.apache.org/jira/browse/ARROW-3652
             Project: Apache Arrow
          Issue Type: Bug
          Components: Python
            Reporter: Armin Berres

When a {{CategoricalIndex}} is written and read back the resulting index is not more categorical.
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')

ref_df = pq.read_pandas('test.parquet').to_pandas()

# CategoricalIndex(['a', 'c'], categories=['a', 'c'], ordered=False, name='c1', dtype='category')

# Index(['a', 'c'], dtype='object', name='c1')
In the metadata the information is correctly contained:
{"name": "c1", "field_name": "c1", "p'
            b'andas_type": "categorical", "numpy_type": "int8", "metadata": {"'
            b'num_categories": 2, "ordered": false}

This message was sent by Atlassian JIRA