Skip to content
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

GH-44188: [Python] Fix pandas roundtrip with bytes column names #44171

Merged
merged 2 commits into from
Feb 27, 2025

Conversation

Piong1997
Copy link
Contributor

@Piong1997 Piong1997 commented Sep 19, 2024

Rationale for this change

There is a bug that when column dtype is np.bytes,it will goto the final branch and run level=level.astype(dtype)

Are these changes tested?

Yes

This comment was marked as outdated.

@Piong1997 Piong1997 changed the title fix pandas_compat.py MINOR: [Python] fix pandas_compat.py Sep 19, 2024
@jorisvandenbossche
Copy link
Member

@Piong1997 do you have a reproducible example that shows the bug? (it would be good to add a test for it)

@Piong1997
Copy link
Contributor Author

Piong1997 commented Sep 20, 2024

@Piong1997 do you have a reproducible example that shows the bug? (it would be good to add a test for it)
@jorisvandenbossche
Sure, the following code reproduce this bug:

import pandas as pd # pd.__version__ is 2.0.3
import pyarrow # pyarrow.__version__ is 17.0.0

df = pd.DataFrame([[0.1, 0.2], [0.3, 0.4]], columns=[b'col1', b'col2'])
table = pyarrow.Table.from_pandas(df)
table.to_pandas() # error occurred

Note that this bug can only be reproduced in pandas 2.0 or above.
This bug was introduced in a certain version of pyarrow, pyarrow version 6.0 can work normally.

@jorisvandenbossche
Copy link
Member

Thanks, that indeed errors right now. Could you add that as a test case in test_pandas.py ?

@Piong1997
Copy link
Contributor Author

Thanks, that indeed errors right now. Could you add that as a test case in test_pandas.py ?

I have already added the case

@jorisvandenbossche jorisvandenbossche changed the title MINOR: [Python] fix pandas_compat.py GH-44188: [Python] Fix pandas roundtrip with bytes column names Sep 23, 2024
Copy link

⚠️ GitHub issue #44188 has been automatically assigned in GitHub to PR creator.

1 similar comment
Copy link

⚠️ GitHub issue #44188 has been automatically assigned in GitHub to PR creator.

Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

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

LGTM, thank you @Piong1997 ! I rebased and will merge if CI is green.

@pitrou
Copy link
Member

pitrou commented Feb 27, 2025

@github-actions crossbow submit pandas

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Feb 27, 2025
Copy link

Revision: e619630

Submitted crossbow builds: ursacomputing/crossbow @ actions-690c1f2da2

Task Status
test-conda-python-3.10-pandas-latest-numpy-latest GitHub Actions
test-conda-python-3.11-pandas-latest-numpy-1.26 GitHub Actions
test-conda-python-3.11-pandas-latest-numpy-latest GitHub Actions
test-conda-python-3.11-pandas-nightly-numpy-nightly GitHub Actions
test-conda-python-3.11-pandas-upstream_devel-numpy-nightly GitHub Actions
test-conda-python-3.9-pandas-1.1.3-numpy-1.19.5 GitHub Actions

@pitrou pitrou merged commit e2ac52d into apache:main Feb 27, 2025
14 checks passed
@pitrou pitrou removed the awaiting committer review Awaiting committer review label Feb 27, 2025
Copy link

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit e2ac52d.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 6 possible false positives for unstable benchmarks that are known to sometimes produce them.

@kou
Copy link
Member

kou commented Mar 1, 2025

@github-actions crossbow submit wheel-windows-cp310-cp310-amd64

Copy link

github-actions bot commented Mar 1, 2025

Revision: e619630

Submitted crossbow builds: ursacomputing/crossbow @ actions-a92b6e4575

Task Status
wheel-windows-cp310-cp310-amd64 GitHub Actions

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

Successfully merging this pull request may close these issues.

4 participants