-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
BUG: to_numeric fails to convert a Pyarrow Decimal series containing NA values #61659
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
BUG: to_numeric fails to convert a Pyarrow Decimal series containing NA values #61659
Conversation
| if is_numeric_dtype(values_dtype): | ||
| if is_series: | ||
| return arg._constructor(values, index=arg.index, name=arg.name) | ||
| else: | ||
| return values |
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.
Could you try to specify if not is_numeric_dtype here, and let the logic below try to convert this case anyways? This short circuit would skip some of the options set in to_numeric
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.
also as @mroeschke suggested in #61641 (comment) documentation update would also be welcome
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.
Thanks @simonjayhawkins , I already create anothter PR for document issue: #61904
simonjayhawkins
left a comment
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.
Thanks @chilin0525 for the PR
| result = to_numeric(series, errors="coerce") | ||
|
|
||
| expected = Series([1.00, pd.NA], dtype=decimal_type) | ||
| tm.assert_series_equal(result, expected) |
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.
IIUC we want a no-op here?
so does
| tm.assert_series_equal(result, expected) | |
| tm.assert_series_equal(result, series) |
work?
| def test_to_numeric_arrow_decimal_with_na(): | ||
| # GH 61641 | ||
| pa = pytest.importorskip("pyarrow") | ||
| decimal_type = ArrowDtype(pa.decimal128(3, scale=2)) |
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.
maybe we could add the dtype as parameterization and also add any other EA dtypes that are expected to no-op?
so we could call the test something like.. test_to_numeric_EA_is_numeric?
| if is_numeric_dtype(values_dtype): | ||
| if is_series: | ||
| return arg._constructor(values, index=arg.index, name=arg.name) | ||
| else: | ||
| return values |
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.
also as @mroeschke suggested in #61641 (comment) documentation update would also be welcome
|
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
|
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |
to_numericfails to convert a Pyarrow Decimal series containing NA values. #61641doc/source/whatsnew/v3.0.0.rstfile if fixing a bug or adding a new feature.