DataSetAttributes.to_arrow

Contents

DataSetAttributes.to_arrow#

DataSetAttributes.to_arrow() pyarrow.Table[source]#

Return this attribute set as a pyarrow.Table.

Each array becomes a column. Multi-component arrays (e.g. a (N, 3) vector field) are expanded to one column per component, named {array_name}_{i}. Only point_data and cell_data can be converted. field_data raises ValueError because its arrays may have differing lengths.

Requires pyarrow.

Returns:
pyarrow.Table

Table with one column per (expanded) array and valid_array_len rows.

Notes

Memory sharing with the underlying VTK buffers is mixed:

  • 1D contiguous numeric columns (scalar arrays) wrap the VTK buffer zero-copy. The Arrow column and the VTK array point at the same memory.

  • Expanded multi-component columns ({name}_{i}) come from strided slices and are copied into contiguous buffers.

  • Booleans, complex numbers, and strings go through pyvista’s existing VTK conversion and are copied.

Arrow buffers are immutable by contract, so consumers cannot mutate VTK memory through the returned table.

Examples

>>> import pyvista as pv
>>> mesh = pv.Cube()
>>> mesh.clear_data()
>>> mesh.point_data['scalars'] = range(mesh.n_points)
>>> table = mesh.point_data.to_arrow()
>>> table.num_rows
8