DataSet.rename_array(old_name: str, new_name: str, preference='cell') None[source]#

Change array name by searching for the array then renaming it.


Name of the array to rename.


Name to rename the array to.

preferencestr, default: “cell”

If there are two arrays of the same name associated with points, cells, or field data, it will prioritize an array matching this type. Can be either 'cell', 'field', or 'point'.


Create a cube, assign a point array to the mesh named 'my_array', and rename it to 'my_renamed_array'.

>>> import pyvista as pv
>>> import numpy as np
>>> cube = pv.Cube()
>>> cube['my_array'] = range(cube.n_points)
>>> cube.rename_array('my_array', 'my_renamed_array')
>>> cube['my_renamed_array']
pyvista_ndarray([0, 1, 2, 3, 4, 5, 6, 7])