pyvista.DataSet.rename_array#

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

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

Parameters:
old_namestr

Name of the array to rename.

new_namestr

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'.

Examples

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])