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

ENH: Utility function to swap all dtypes numpypyarrow #53648

Closed
2 of 3 tasks
randolf-scholz opened this issue Jun 13, 2023 · 0 comments · Fixed by #53651
Closed
2 of 3 tasks

ENH: Utility function to swap all dtypes numpypyarrow #53648

randolf-scholz opened this issue Jun 13, 2023 · 0 comments · Fixed by #53651
Labels
Arrow pyarrow functionality Bug

Comments

@randolf-scholz
Copy link
Contributor

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

It would be nice to have a utility function that swaps the backend of all dtypes of an existing DataFrame/Series/Index.

Feature Description

One could consider repurposing the DataFrame.convert_dtypes for this functionality.

Currently, it does nothing:

import numpy as np
import pandas as pd
import pyarrow as pa

s_arrow = pd.Series(np.arange(100), dtype="int32[pyarrow]")
s_numpy = pd.Series(np.arange(100), dtype="Int32")

s = s_arrow.convert_dtypes(dtype_backend="numpy_nullable")
assert s_numpy.dtype == s.dtype  # ✘ AssertionError

Alternative Solutions

Potentially, one could also allow passing a transformation schema dict[input_type, output_type] to the astype function.

Additional Context

No response

@randolf-scholz randolf-scholz added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 13, 2023
@mroeschke mroeschke added Bug Arrow pyarrow functionality and removed Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 13, 2023
HyukjinKwon pushed a commit to apache/spark that referenced this issue Jul 10, 2023
### What changes were proposed in this pull request?
The pr aims to upgrade `pandas` from 2.0.2 to 2.0.3.

### Why are the changes needed?
1.The new version brings some bug fixed, eg:
- Bug in DataFrame.convert_dtype() and Series.convert_dtype() when trying to convert [ArrowDtype](https://pandas.pydata.org/docs/reference/api/pandas.ArrowDtype.html#pandas.ArrowDtype) with dtype_backend="nullable_numpy" ([GH53648](pandas-dev/pandas#53648))

- Bug in [read_csv()](https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html#pandas.read_csv) when defining dtype with bool[pyarrow] for the "c" and "python" engines ([GH53390](pandas-dev/pandas#53390))

2.Release notes:
https://pandas.pydata.org/docs/whatsnew/v2.0.3.html

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Pass GA.

Closes #41812 from panbingkun/SPARK-44267.

Authored-by: panbingkun <pbk1982@gmail.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
ragnarok56 pushed a commit to ragnarok56/spark that referenced this issue Mar 2, 2024
### What changes were proposed in this pull request?
The pr aims to upgrade `pandas` from 2.0.2 to 2.0.3.

### Why are the changes needed?
1.The new version brings some bug fixed, eg:
- Bug in DataFrame.convert_dtype() and Series.convert_dtype() when trying to convert [ArrowDtype](https://pandas.pydata.org/docs/reference/api/pandas.ArrowDtype.html#pandas.ArrowDtype) with dtype_backend="nullable_numpy" ([GH53648](pandas-dev/pandas#53648))

- Bug in [read_csv()](https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html#pandas.read_csv) when defining dtype with bool[pyarrow] for the "c" and "python" engines ([GH53390](pandas-dev/pandas#53390))

2.Release notes:
https://pandas.pydata.org/docs/whatsnew/v2.0.3.html

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Pass GA.

Closes apache#41812 from panbingkun/SPARK-44267.

Authored-by: panbingkun <pbk1982@gmail.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants