Kayvan-Zahiri opened a new issue, #51046:
URL: https://github.com/apache/arrow/issues/51046

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   `pyarrow.interchange.from_dataframe` builds the dictionary array without the 
`is_ordered` flag the producer reports, so an ordered categorical column comes 
back unordered. A pyarrow table whose column is `dictionary(int32, string, 
ordered=True)` does not survive its own round trip, and an ordered pandas 
`Categorical` loses its ordering on the way in.
   
   ```python
   import pyarrow as pa
   from pyarrow.interchange import from_dataframe
   
   t = pa.table({"c": pa.array(["a", "b", "a"]).dictionary_encode().cast(
       pa.dictionary(pa.int32(), pa.string(), ordered=True))})
   print(t.schema.field("c").type.ordered)                    # True
   print(from_dataframe(t).schema.field("c").type.ordered)    # False
   ```
   
   The interchange protocol exposes the flag: a categorical column's 
`describe_categorical` returns `is_ordered`, and the pandas consumer passes it 
through. The pyarrow consumer reads the mapping but drops `is_ordered`.
   
   ### Component(s)
   
   Python
   


-- 
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]

Reply via email to