rename_array

ExplicitStructuredGrid.rename_array(old_name: str, new_name: str, preference='cell')

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, optional

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
>>> import numpy as np
>>> cube = pyvista.Cube().clean()
>>> cube['my_array'] = range(cube.n_points)
>>> cube.rename_array('my_array', 'my_renamed_array')
>>> cube['my_renamed_array']
array([0, 1, 2, 3, 4, 5, 6, 7])