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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
