Objects

The pyvista.DataObject class is a set of common methods and attributes for all PyVista types. These objects have no spatial reference, but simply hold data.

Attributes

field_arrays

Return vtkFieldData as DataSetAttributes.

memory_address

Get address of the underlying C++ object in format ‘Addr=%p’.

Methods

add_field_array(scalars, name[, deep])

Add a field array.

clear_field_arrays()

Remove all field arrays.

copy([deep])

Return a copy of the object.

copy_meta_from(ido)

Copy pyvista meta data onto this object from another object.

deep_copy(to_copy)

Overwrite this mesh with the given mesh as a deep copy.

get_data_range([arr, preference])

Get the non-NaN min and max of a named array.

head([display, html])

Return the header stats of this dataset.

save(filename[, binary])

Save this vtk object to file.

shallow_copy(to_copy)

Shallow copy the given mesh to this mesh.

class pyvista.DataObject(*args, **kwargs)

Bases: object

Methods common to all wrapped data objects.

add_field_array(scalars, name, deep=True)

Add a field array.

clear_field_arrays()

Remove all field arrays.

copy(deep=True)

Return a copy of the object.

Parameters

deep (bool, optional) – When True makes a full copy of the object.

Returns

newobject – Deep or shallow copy of the input.

Return type

same as input

copy_meta_from(ido)

Copy pyvista meta data onto this object from another object.

deep_copy(to_copy)

Overwrite this mesh with the given mesh as a deep copy.

property field_arrays

Return vtkFieldData as DataSetAttributes.

get_data_range(arr=None, preference='field')

Get the non-NaN min and max of a named array.

Parameters
  • arr (str, np.ndarray, optional) – The name of the array to get the range. If None, the active scalar is used

  • preference (str, optional) – When scalars is specified, this is the preferred array type to search for in the dataset. Must be either 'point', 'cell', or 'field'.

head(display=True, html=None)

Return the header stats of this dataset.

If in IPython, this will be formatted to HTML. Otherwise returns a console friendly string.

property memory_address

Get address of the underlying C++ object in format ‘Addr=%p’.

save(filename, binary=True)

Save this vtk object to file.

Parameters
  • filename (str) – Filename of output file. Writer type is inferred from the extension of the filename.

  • binary (bool, optional) – If True, write as binary, else ASCII.

Notes

Binary files write much faster than ASCII and have a smaller file size.

shallow_copy(to_copy)

Shallow copy the given mesh to this mesh.

Table

The table class is a non-spatially referenced data object that can be used on VTK pipelines and holds arrays of data.

Attributes

n_arrays

Return the number of columns.

n_columns

Return the number of columns.

n_rows

Return the number of rows.

row_arrays

Return the all row arrays.

Methods

get(index)

Get an array by its name.

get_data_range([arr, preference])

Get the non-NaN min and max of a named array.

items()

Return the table items.

keys()

Return the table keys.

pop(name)

Pops off an array by the specified name.

save(*args, **kwargs)

Save the table.

to_pandas()

Create a Pandas DataFrame from this Table.

update(data)

Set the table data.

values()

Return the table values.

class pyvista.Table(*args, **kwargs)

Bases: vtkmodules.vtkCommonDataModel.vtkTable, pyvista.core.common.DataObject

Wrapper for the vtkTable class.

Create by passing a 2D NumPy array of shape (n_rows by n_columns) or from a dictionary containing NumPy arrays.

Example

>>> import pyvista as pv
>>> import numpy as np
>>> arrays = np.random.rand(100, 3)
>>> table = pv.Table(arrays)
get(index)

Get an array by its name.

get_data_range(arr=None, preference='row')

Get the non-NaN min and max of a named array.

Parameters
  • arr (str, np.ndarray, optional) – The name of the array to get the range. If None, the active scalar is used

  • preference (str, optional) – When scalars is specified, this is the preferred array type to search for in the dataset. Must be either 'row' or 'field'.

items()

Return the table items.

keys()

Return the table keys.

property n_arrays

Return the number of columns.

Alias for: n_columns.

property n_columns

Return the number of columns.

property n_rows

Return the number of rows.

pop(name)

Pops off an array by the specified name.

property row_arrays

Return the all row arrays.

save(*args, **kwargs)

Save the table.

to_pandas()

Create a Pandas DataFrame from this Table.

update(data)

Set the table data.

values()

Return the table values.