DataSetAttributes.get_array#
- DataSetAttributes.get_array(key: str | int) pyvista_ndarray[source]#
Get an array in this object.
- Parameters:
- Returns:
- Raises:
KeyErrorIf the key does not exist.
Notes#
This is provided since arrays are ordered within VTK and can
be indexed via an int. When getting an array, you can just
use the key of the array with the [] operator with the
name of the array.
Examples#
Download Python source code | Download Jupyter notebook
Store data with point association in a DataSet.
>>> import pyvista as pv
>>> mesh = pv.Cube()
>>> mesh.clear_data()
>>> mesh.point_data['my_data'] = range(mesh.n_points)
Access using an index.
>>> mesh.point_data.get_array(0)
pyvista_ndarray([0, 1, 2, 3, 4, 5, 6, 7])
Access using a key.
>>> mesh.point_data.get_array('my_data')
pyvista_ndarray([0, 1, 2, 3, 4, 5, 6, 7])