Skip to content

BUG: pyarrow dictionary type ordered argument not respected #58152

@WillAyd

Description

@WillAyd
Member

Pandas version checks

  • I have checked that this issue has not already been reported.

    I have confirmed this bug exists on the latest version of pandas.

    I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

>>> dicttyp = pa.dictionary(pa.int8(), pa.string(), ordered=True)
>>> dicttyp.ordered
>>> pd.Series(["foo", "bar", "foo"], dtype=pd.ArrowDtype(dicttyp))
0    foo
1    bar
2    foo
dtype: dictionary<values=string, indices=int8, ordered=0>[pyarrow]


### Issue Description

The pyarrow type above is ordered, but that gets lost when forwarded to pandas

### Expected Behavior

order should be respected

### Installed Versions

main

Activity

added
Needs TriageIssue that has not been reviewed by a pandas team member
pyarrow dtype retentionop with pyarrow dtype -> expect pyarrow result
and removed
Needs TriageIssue that has not been reviewed by a pandas team member
on Apr 4, 2024
mroeschke

mroeschke commented on Apr 4, 2024

@mroeschke
Member

Looks to be a pyarrow bug

In [7]: pa.__version__
Out[7]: '15.0.1'

In [8]: dicttyp
Out[8]: DictionaryType(dictionary<values=string, indices=int8, ordered=1>)

In [9]: pa.array(["foo", "bar", "foo"], dicttyp).type
Out[9]: DictionaryType(dictionary<values=string, indices=int8, ordered=0>)
WillAyd

WillAyd commented on Apr 4, 2024

@WillAyd
MemberAuthor

Very nice catch. Just opened apache/arrow#41017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arrowpyarrow functionalityBugUpstream issueIssue related to pandas dependencypyarrow dtype retentionop with pyarrow dtype -> expect pyarrow result

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @WillAyd@mroeschke

        Issue actions

          BUG: pyarrow dictionary type ordered argument not respected · Issue #58152 · pandas-dev/pandas