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 all field arrays.

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

Write this mesh to a 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 all field arrays.

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

Write this mesh to a file.

Parameters
  • filename (str) – Filename of mesh to be written. File type is inferred from the extension of the filename unless overridden with ftype.

  • binary (bool, optional) – Writes the file as binary when True and ASCII when False.

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.

next()

Get the next block from the iterator.

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: vtkCommonDataModelPython.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 perfered 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.

next()

Get the next block from the iterator.

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.