Skip to content

Commit 2e9de89

Browse files
GH-49644: [Python] Add a docstring example for building from a list of arrays
1 parent cf4aa91 commit 2e9de89

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

python/pyarrow/array.pxi

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4708,6 +4708,30 @@ cdef class FixedShapeTensorArray(ExtensionArray):
47084708
400
47094709
]
47104710
]
4711+
4712+
Create an extension array from a list of multi-dimensional NumPy arrays.
4713+
Each element is flattened in row-major (C) order, and its shape must match
4714+
the tensor shape.
4715+
4716+
>>> import numpy as np
4717+
>>> pa.array([np.array([[1, 2], [3, 4]], dtype=np.int32),
4718+
... np.array([[10, 20], [30, 40]], dtype=np.int32)],
4719+
... type=tensor_type)
4720+
<pyarrow.lib.FixedShapeTensorArray object at ...>
4721+
[
4722+
[
4723+
1,
4724+
2,
4725+
3,
4726+
4
4727+
],
4728+
[
4729+
10,
4730+
20,
4731+
30,
4732+
40
4733+
]
4734+
]
47114735
"""
47124736

47134737
def to_numpy_ndarray(self):

0 commit comments

Comments
 (0)