-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Open
Labels
Component: PythonStatus: stale-warningIssues and PRs flagged as stale which are due to be closed if no indication otherwiseIssues and PRs flagged as stale which are due to be closed if no indication otherwiseType: enhancement
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']>Reporter: Antoine Pitrou / @pitrou
Related issues:
Note: This issue was originally created as ARROW-16254. Please see the migration documentation for further details.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Component: PythonStatus: stale-warningIssues and PRs flagged as stale which are due to be closed if no indication otherwiseIssues and PRs flagged as stale which are due to be closed if no indication otherwiseType: enhancement