-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: to_numeric(errors='coerce', dtype_backend='pyarrow') with ArrowDtype #52606
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
Conversation
pandas/core/tools/numeric.py
Outdated
@@ -275,7 +275,8 @@ def to_numeric( | |||
# GH33013: for IntegerArray, BooleanArray & FloatingArray need to reconstruct | |||
# masked array | |||
if (mask is not None or new_mask is not None) and not is_string_dtype(values.dtype): | |||
if mask is None: | |||
if mask is None or (new_mask is not None and errors == "coerce"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't really think about a case right now, but I think new_mask.shape == mask.shape
instead of errors="coerce"
is safer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I'll change it to that
pandas/core/tools/numeric.py
Outdated
@@ -275,7 +275,9 @@ def to_numeric( | |||
# GH33013: for IntegerArray, BooleanArray & FloatingArray need to reconstruct | |||
# masked array | |||
if (mask is not None or new_mask is not None) and not is_string_dtype(values.dtype): | |||
if mask is None or (new_mask is not None and errors == "coerce"): | |||
if mask is None or ( | |||
mask is not None and new_mask is not None and new_mask.shape == mask.shape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove the mask is not None
, this is covered by the first condition
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove the If these instructions are inaccurate, feel free to suggest an improvement. |
@meeseeksmachine backport 2.0.x |
@meeseeksdev backport 2.0.x |
…backend='pyarrow') with ArrowDtype
…dtype_backend='pyarrow') with ArrowDtype) (#52611) Backport PR #52606: BUG: to_numeric(errors='coerce', dtype_backend='pyarrow') with ArrowDtype Co-authored-by: Matthew Roeschke <[email protected]>
pd.to_numeric(.., dtype_backend='pyarrow')
crashes forstring[pyarrow]
#52588 (Replace xxxx with the GitHub issue number)doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.