You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "shashbha14 (via GitHub)" <gi...@apache.org> on 2026/01/26 15:17:15 UTC
[PR] GH-48972: [Python] Add errors='coerce' parameter to pyarrow.compute.cast [arrow]
shashbha14 opened a new pull request, #48994:
URL: https://github.com/apache/arrow/pull/48994
### Rationale for this change
Currently, `pyarrow.compute.cast()` raises an exception when encountering values that cannot be cast to the target type. This PR adds an `errors` parameter (similar to `pandas.to_numeric(errors='coerce')`) to allow gracefully handling cast failures by converting them to null values.
### What changes are included in this PR?
- Added `errors` parameter to `cast()` function with options `'raise'` (default) and `'coerce'`
- When `errors='coerce'`, sets `CastOptions.null_on_error = True` to produce nulls for invalid casts
- Added `is_castable()` meta-function to check element-wise castability
- Comprehensive test suite in `test_coerce_cast.py`
### Are these changes tested?
Yes, added extensive tests covering:
- Basic coercion behavior
- Edge cases (empty strings, "nan", None values)
- Temporal type casting
- Integration with existing `safe` parameter
- Instance methods (`array.cast()`, `chunked_array.cast()`)
- Error validation
### Are there any user-facing changes?
Yes - new `errors` parameter for `pyarrow.compute.cast()` and new `is_castable()` function.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-48972: [Python] Add errors='coerce' parameter to pyarrow.compute.cast [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok closed pull request #48994: GH-48972: [Python] Add errors='coerce' parameter to pyarrow.compute.cast
URL: https://github.com/apache/arrow/pull/48994
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-48972: [Python] Add errors='coerce' parameter to pyarrow.compute.cast [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on PR #48994:
URL: https://github.com/apache/arrow/pull/48994#issuecomment-3880235961
@shashbha14 please feel free to reopen if you want to continue the work.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-48972: [Python] Add errors='coerce' parameter to pyarrow.compute.cast [arrow]
Posted by "raulcd (via GitHub)" <gi...@apache.org>.
raulcd commented on code in PR #48994:
URL: https://github.com/apache/arrow/pull/48994#discussion_r2736255815
##########
python/pyarrow/table.pxi:
##########
@@ -2105,6 +2116,17 @@ cdef class _Tabular(_PandasConvertible):
"""
return (self.num_rows, self.num_columns)
+ @property
+ def personal_data(self):
+ """
+ Whether the object contains personal data.
+
+ Returns
+ -------
+ personal_data : bool
+ """
+ return self.schema.personal_data
+
Review Comment:
this seems completely unrelated.
##########
dev/release/download_rc_binaries.py:
##########
Review Comment:
the commit updating this shouldn't be part of this PR, right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-48972: [Python] Add errors='coerce' parameter to pyarrow.compute.cast [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on PR #48994:
URL: https://github.com/apache/arrow/pull/48994#issuecomment-3880229520
Closing for lack of activity.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org