jay23606 opened a new pull request, #55477:
URL: https://github.com/apache/arrow/pull/55477
## Problem
When `pa.array()` is called without `from_pandas`, it sets
`from_pandas=True` automatically only for pandas Series and Index inputs. A
pandas ExtensionArray such as `pd.array([1.2, np.nan], dtype=float)` was not
detected, so NaN was kept as NaN instead of being converted to null, unlike the
Series case.
## Change
In `get_values` (`python/pyarrow/array.pxi`), the generic branch now sets
`is_pandas_object` when the input has an extension dtype
(`pandas_api.is_extension_array_dtype(obj)`). Plain lists and numpy arrays keep
the existing behaviour.
## Testing
Added `test_pandas_null_sentinels_extension_array` in
`python/pyarrow/tests/test_array.py`. It checks that `pa.array(pd.array([1.2,
np.nan], dtype=float))` equals the `from_pandas=True` result and has one null.
The test could not be run in this environment because pyarrow is not built
here, so it is verified by CI only. Only a syntax check was run locally:
`python -c "import ast,sys;
ast.parse(open('python/pyarrow/tests/test_array.py',encoding='utf-8').read());
print('syntax ok')"`.
**Regression test:** untested: CONTRIBUTING does not mention tests
Fixes #35721
--
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]