Skip to content

ENH: Add misc pyarrow types to ArrowDtype.type #51854

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 10, 2023

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke added the Arrow pyarrow functionality label Mar 9, 2023
@mroeschke mroeschke added this to the 2.0 milestone Mar 9, 2023
elif pa.types.is_dictionary(pa_type):
from pandas.core.arrays import Categorical

return Categorical
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbrockmendel you had mentioned type should be the type of the associated scalar.

For our the CategoricalDtype.type this CategoricalDtypeType, but I guess we don't have a categorical scalar per se?
For ArrowDtype.type should we use CategoricalDtypeType here or the type of the categorical values instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id be OK either way. CategoricalDtypeType seems like the safe option internal-consistency wise, but seems pretty useless for a user

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, would it be okay to return a Categorical here? The "scalar" could be a length 1 Categorical in practice but I'm not sure if that breaks the mental model of anything else

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems really weird to me. Is there some test(s) that are easier to fix with that than with either of the other options?

We should probably deprecate/change CategoricalDtype.type at some point and ensure these match.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this makes other tests easier as of yet since we don't test pa.dictionary fully yet.

Will just use CategoricalDtypeType here for now.

# TODO: Potentially change this & CategoricalDtype.type to
# something more representative of the scalar
return CategoricalDtypeType
elif pa.types.is_list(pa_type) or pa.types.is_large_list(pa_type):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

side note: think with this supported we can get rid of JSONArray?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think we can get rid of the date and decimal arrays now since they have corresponding arrow types tested and json and list arrays once we add tests for those arrow types

Copy link
Member

@jbrockmendel jbrockmendel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mroeschke mroeschke merged commit af43bfc into pandas-dev:main Mar 10, 2023
@mroeschke mroeschke deleted the bug/arrow/misc_types branch March 10, 2023 19:49
meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Mar 10, 2023
mroeschke added a commit that referenced this pull request Mar 10, 2023
…rowDtype.type) (#51887)

Backport PR #51854: ENH: Add misc pyarrow types to ArrowDtype.type

Co-authored-by: Matthew Roeschke <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Pandas 2.0rc0 can't handle string column with PyArrow (large_string error)
2 participants