You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Antoine Pitrou / @pitrou:
I think allowing Arrays is fine. I'm not sure we want to make Scalars first-class citizens like Numpy scalars, though. At least from an implementation POV, it may add a lot of code all over the place...
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:
A "simple" workaround would be to invoke Scalars' as_py method if they're passed in. That would add perf overhead, though, since we'd need to do isinstance checks.
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
Activity
asfimport commentedon May 9, 2019
Antoine Pitrou / @pitrou:
I think allowing Arrays is fine. I'm not sure we want to make Scalars first-class citizens like Numpy scalars, though. At least from an implementation POV, it may add a lot of code all over the place...
asfimport commentedon Aug 13, 2019
Joris Van den Bossche / @jorisvandenbossche:
Additional case (from ARROW-6222): pyarrow Arrays are also not recognized as list-like when converting/inferring a list array:
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)
asfimport commentedon Aug 22, 2019
Wes McKinney / @wesm:
A "simple" workaround would be to invoke Scalars'
as_pymethod if they're passed in. That would add perf overhead, though, since we'd need to doisinstancechecks.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
jorisvandenbossche commentedon Mar 2, 2023
The part about accepting an Array object is solved now with #34275. Leaving this issue open for the Scalar case.
Merge branch 'main' into apachegh-21761-array-accepting-scalars
GH-21761: [Python] accept pyarrow scalars in array constructor (#36162)