pyvista.DataSetAttributes.pop

pyvista.DataSetAttributes.pop#

DataSetAttributes.pop(
key: str,
default: pyvista_ndarray | T = pyvista_ndarray([], dtype=float64),
) pyvista_ndarray | T[source]#

Remove an array and return it.

Parameters:
keystr

The name of the array to remove and return.

defaultAny, optional

If default is not given and key is not in the dictionary, a KeyError is raised.

Returns:
pyvista_ndarray

Requested array.

Examples

Add a point data array to a DataSet and then remove it.

>>> import pyvista as pv
>>> mesh = pv.Cube()
>>> mesh.point_data['my_data'] = range(mesh.n_points)
>>> mesh.point_data.pop('my_data')
pyvista_ndarray([0, 1, 2, 3, 4, 5, 6, 7])

Show that the array no longer exists in point_data.

>>> 'my_data' in mesh.point_data
False