Files
arrow/python
Antoine Prouvost 987e2312c3 GH-38868: [C++][Python] Add Array::ToTensor and fixed size list support (#50929)
### Rationale for this change
Enable multidimensional DLPack support for Array via `to_tensor`.

### What changes are included in this PR?
- Add virtual `Array::ToTensor`
- Add `NumericArray::ToTensor` for 1D arrays
- Add `FixedSizeListArray::ToTensor` for multidimensional arrays
- Add DLPack error suggestiong tensor convertion
- Add DLPack tests with `arr.to_tensor().__dlpack__()`

Note: Nulls are explicitly supported in `to_tensor` as unspecified data. This was the current behaviour.

### Are these changes tested?
Yes

### Are there any user-facing changes?
New public Array function.

* GitHub Issue: #38868

Authored-by: AntoinePrv <AntoinePrv@users.noreply.github.com>
Signed-off-by: Antoine Pitrou <antoine@python.org>
2026-09-03 12:09:07 +02:00
..

Python library for Apache Arrow

pypi conda-forge

This library provides a Python API for functionality provided by the Arrow C++ libraries, along with tools for Arrow integration and interoperability with pandas, NumPy, and other software in the Python ecosystem.

Installing

Across platforms, you can install a recent version of pyarrow with the conda package manager:

conda install pyarrow -c conda-forge

On Linux, macOS, and Windows, you can also install binary wheels from PyPI with pip:

pip install pyarrow

If you encounter any issues importing the pip wheels on Windows, you may need to install the latest Visual C++ Redistributable for Visual Studio.

Development

See Python Development in the documentation subproject.

Building the documentation

See documentation build instructions in the documentation subproject.