galipremsagar commented on issue #15178:
URL: https://github.com/apache/arrow/issues/15178#issuecomment-1370198289
Worth noting that performing a `slice` operation also seems to be dropping
the index after round-trip:
```python
In [18]: df.index = pd.RangeIndex(2, 10, 2)
In [19]: table = pa.Table.from_pandas(df)
In [20]: table.schema.pandas_metadata
Out[20]:
{'index_columns': [{'kind': 'range',
'name': None,
'start': 2,
'stop': 10,
'step': 2}],
'column_indexes': [{'name': None,
'field_name': None,
'pandas_type': 'unicode',
'numpy_type': 'object',
'metadata': {'encoding': 'UTF-8'}}],
'columns': [{'name': 'n_legs',
'field_name': 'n_legs',
'pandas_type': 'int64',
'numpy_type': 'int64',
'metadata': None},
{'name': 'animals',
'field_name': 'animals',
'pandas_type': 'unicode',
'numpy_type': 'object',
'metadata': None}],
'creator': {'library': 'pyarrow', 'version': '10.0.1'},
'pandas_version': '1.5.2'}
In [21]: table.slice(0, 2)
Out[21]:
pyarrow.Table
n_legs: int64
animals: string
----
n_legs: [[2,4]]
animals: [["Flamingo","Horse"]]
In [22]: table.slice(0, 2).to_pandas()
Out[22]:
n_legs animals
0 2 Flamingo
1 4 Horse
In [23]: df
Out[23]:
n_legs animals
2 2 Flamingo
4 4 Horse
6 5 Brittle stars
8 100 Centipede
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]