Alenka Frim created ARROW-15565:
-----------------------------------
Summary: [Python] Interval dtype is not preserved on a roundtrip
from Pandas and IntervalIndex
Key: ARROW-15565
URL: https://issues.apache.org/jira/browse/ARROW-15565
Project: Apache Arrow
Issue Type: Improvement
Components: Python
Reporter: Alenka Frim
Doing a roundtrip from Pandas with IntervalIndex results in an object-dtype
index, and not a proper Intervalndex - that means the interval dtype is not
preserved on a roundtrip, while this would be the case if it was a normal
column instead of the index.
Example:
{code}
>>> import pandas as pd
>>> import pyarrow as pa
>>> df = pd.DataFrame(index=pd.interval_range(start=0, end=3))
>>> table = pa.table(df)
>>> table.to_pandas().index
Index([{'left': 0, 'right': 1}, {'left': 1, 'right': 2},
{'left': 2, 'right': 3}],
dtype='object')
>>> df.index
IntervalIndex([(0, 1], (1, 2], (2, 3]], dtype='interval[int64, right]')
>>>
{code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)