Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Currently, to create a Scalar instance you must call the pa.scalar factory function. This works fine for the simplest types, but not for more elaborate ones.
For example, in C++ it is trivial to create a ListScalar from the embedded std::shared_ptr<Array>. But not in Python:
>>> arr = pa.array(["abc", "def", "ghi"]) >>> pa.ListScalar(arr) Traceback (most recent call last): Input In [7] in <cell line: 1> pa.ListScalar(arr) TypeError: __init__() takes exactly 0 positional arguments (1 given)
There is a clumsy workaround that creates an intermediate ListArray with trivial offsets:
>>> list_arr = pa.ListArray.from_arrays([0, len(arr)], arr) >>> list_arr[0] <pyarrow.ListScalar: ['abc', 'def', 'ghi']>
Attachments
Issue Links
- is related to
-
ARROW-5295 [Python] accept pyarrow values / scalars in constructor functions ?
- Open