[
https://issues.apache.org/jira/browse/ARROW-16254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17525941#comment-17525941
]
Joris Van den Bossche commented on ARROW-16254:
-----------------------------------------------
Ah, yes. Now, that relates to the issue that {{pa.array(..)}} also does not
accept pyarrow arrays as scalars, see ARROW-5295
> [Python] Scalar constructors should be callable
> -----------------------------------------------
>
> Key: ARROW-16254
> URL: https://issues.apache.org/jira/browse/ARROW-16254
> Project: Apache Arrow
> Issue Type: Improvement
> Components: Python
> Reporter: Antoine Pitrou
> Priority: Major
> Fix For: 9.0.0
>
>
> 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:
> {code: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)
> {code}
> There is a clumsy workaround that creates an intermediate {{ListArray}} with
> trivial offsets:
> {code:python}
> >>> list_arr = pa.ListArray.from_arrays([0, len(arr)], arr)
> >>> list_arr[0]
> <pyarrow.ListScalar: ['abc', 'def', 'ghi']>
> {code}
--
This message was sent by Atlassian Jira
(v8.20.7#820007)