[
https://issues.apache.org/jira/browse/ARROW-15033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17456454#comment-17456454
]
Vlad Firoiu edited comment on ARROW-15033 at 12/9/21, 1:56 PM:
---------------------------------------------------------------
Current workaround is to use a {{StructArray}} with keys {{('0', '1', ...)}}
instead:
{code:python}
int32 = pa.int64()
type_ = pa.struct({'0': int32, '1': int32, '2': int32})
reference = pa.array([
{'0': 1, '1': 2, '2': 3},
{'0': 4, '1': 5, '2': 6},
], type=type_)
sub_arrays = [
pa.array([1, 4]),
pa.array([2, 5]),
pa.array([3, 6]),
]
struct_array = pa.StructArray.from_arrays(sub_arrays, names=['0', '1', '2'])
assert struct_array == reference
{code}
was (Author: JIRAUSER281417):
Current workaround is to use a {{StructArray}} with keys {{('0', '1', ...)}}
instead.
> [Python] No way to create ListArray from sub-arrays
> ---------------------------------------------------
>
> Key: ARROW-15033
> URL: https://issues.apache.org/jira/browse/ARROW-15033
> Project: Apache Arrow
> Issue Type: New Feature
> Components: Python
> Reporter: Vlad Firoiu
> Priority: Major
>
> I'd like to create a `ListArray` from a list of sub-arrays, similar to how
> `StructArray.from_arrays` can create a `StructArray` from a sequence of names
> and arrays. A similarly-named function, `ListArray.from_arrays` does exist,
> but it does something completely different.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)