Repository navigation
GH-45175: [Python] Honor the strings_to_categorical keyword in to_pandas for string view type - #45176
Merged
raulcd merged 2 commits intoJan 7, 2025
Conversation
|
|
raulcd
approved these changes
Jan 7, 2025
raulcd
left a comment
Member
There was a problem hiding this comment.
Thanks @jorisvandenbossche
I've learnt today that Table.__getitem__ returns a ChunkedArray.
I am going to merge this. Where you expecting this to go on 19.0.0? cc @amoeba
amoeba
pushed a commit
that referenced
this pull request
Jan 7, 2025
…das for string view type (#45176) ### Rationale for this change Currently this keyword works for string or large string: ```python >>> table = pa.table({"col": pa.array(["a", "b", "a"], pa.string())}) >>> table.to_pandas(strings_to_categorical=True).dtypes col category dtype: object >>> table = pa.table({"col": pa.array(["a", "b", "a"], pa.large_string())}) >>> table.to_pandas(strings_to_categorical=True).dtypes col category dtype: object ``` but not for string view: ```python >>> table = pa.table({"col": pa.array(["a", "b", "a"], pa.string_view())}) >>> table.to_pandas(strings_to_categorical=True).dtypes col object dtype: object ``` For consistency we should make that keyword check for string view columns as well, I think From https://github.com/apache/arrow/pull/44195/files#r1901831460 ### Are these changes tested? Yes ### Are there any user-facing changes? Yes, when using the `strings_to_categorical=True` keyword and having a string_view type, this column will now be converted to a pandas Categorical * GitHub Issue: #45175 Authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Raúl Cumplido <[email protected]>
amoeba
pushed a commit
that referenced
this pull request
Jan 11, 2025
…das for string view type (#45176) ### Rationale for this change Currently this keyword works for string or large string: ```python >>> table = pa.table({"col": pa.array(["a", "b", "a"], pa.string())}) >>> table.to_pandas(strings_to_categorical=True).dtypes col category dtype: object >>> table = pa.table({"col": pa.array(["a", "b", "a"], pa.large_string())}) >>> table.to_pandas(strings_to_categorical=True).dtypes col category dtype: object ``` but not for string view: ```python >>> table = pa.table({"col": pa.array(["a", "b", "a"], pa.string_view())}) >>> table.to_pandas(strings_to_categorical=True).dtypes col object dtype: object ``` For consistency we should make that keyword check for string view columns as well, I think From https://github.com/apache/arrow/pull/44195/files#r1901831460 ### Are these changes tested? Yes ### Are there any user-facing changes? Yes, when using the `strings_to_categorical=True` keyword and having a string_view type, this column will now be converted to a pandas Categorical * GitHub Issue: #45175 Authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Raúl Cumplido <[email protected]>
|
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 2c5ae51. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 1 possible false positive for unstable benchmarks that are known to sometimes produce them. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Currently this keyword works for string or large string:
but not for string view:
For consistency we should make that keyword check for string view columns as well, I think
From https://github.com/apache/arrow/pull/44195/files#r1901831460
Are these changes tested?
Yes
Are there any user-facing changes?
Yes, when using the
strings_to_categorical=Truekeyword and having a string_view type, this column will now be converted to a pandas Categoricalto_pandasfor string view type #45175