-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Python] accept pyarrow values / scalars in constructor functions ? #21761
Comments
Antoine Pitrou / @pitrou: |
Joris Van den Bossche / @jorisvandenbossche: In [43]: pa.array([np.array([1, 1]), np.array([2, 2, 2])])
Out[43]:
<pyarrow.lib.ListArray object at 0x7f258fa9d0a0>
[
[
1,
1
],
[
2,
2,
2
]
]
In [44]: pa.array([pa.array([1, 1]), pa.array([2, 2, 2])])
---------------------------------------------------------------------------
ArrowInvalid Traceback (most recent call last)
<ipython-input-44-a22e0a500750> in <module>
----> 1 pa.array([pa.array([1, 1]), pa.array([2, 2, 2])])
~/scipy/repos/arrow/python/pyarrow/array.pxi in pyarrow.lib.array()
~/scipy/repos/arrow/python/pyarrow/array.pxi in pyarrow.lib._sequence_to_array()
~/scipy/repos/arrow/python/pyarrow/error.pxi in pyarrow.lib.check_status()
ArrowInvalid: Could not convert [
1,
1
] with type pyarrow.lib.Int64Array: did not recognize Python value type when inferring an Arrow data type So list (or array) of numpy arrays works, but list of pyarrow arrays not. Again, not the most typical use case of pyarrow Arrays, so not sure we should add this capability. (although we might want to find a general solution for array-like objects (eg pytorch.Tensors, see ARROW-6222), and a solution for that (somehow trying to coerce to a numpy array?) might also solve the case of a list of arrow arrays) |
Wes McKinney / @wesm: Another option is to "sanitize" inputs (using a helper function) only in the case of failure on the initial try. So the normal use case won't be affected |
The part about accepting an Array object is solved now with #34275. Leaving this issue open for the Scalar case. |
### Rationale for this change Currently, `pyarrow.array `doesn't accept list of pyarrow Scalars and this PR adds a check to allow that. * Closes: #21761 Lead-authored-by: AlenkaF <[email protected]> Co-authored-by: Alenka Frim <[email protected]> Co-authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
Currently, functions like `pyarrow.array` don't accept pyarrow Arrays, or also not scalars of it:
Do we want to allow those / recognize those here? (the first case could even have a fastpath, as we don't need to do it element by element).
Also scalars are not supported:
And also in other functions we don't accept arrow scalars / values:
Reporter: Joris Van den Bossche / @jorisvandenbossche
Related issues:
Note: This issue was originally created as ARROW-5295. Please see the migration documentation for further details.
The text was updated successfully, but these errors were encountered: