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

Returns all field arrays

Methods

add_field_array(scalars, name[, deep])

clear_field_arrays()

removes all field arrays

copy([deep])

Returns a copy of the object

copy_meta_from(ido)

Copies pyvista meta data onto this object from another object

get_data_range([arr, preference])

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

head([display, html])

Return the header stats of this dataset.

save(filename[, binary])

Writes this mesh to a file.

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

Bases: object

Methods common to all wrapped data objects

add_field_array(scalars, name, deep=True)
clear_field_arrays()

removes all field arrays

copy(deep=True)

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

Copies pyvista meta data onto this object from another object

property field_arrays

Returns all field arrays

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

Get the non-NaN min and max of a named scalar 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 scalar 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

save(filename, binary=True)

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

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

n_columns

n_rows

row_arrays

Returns 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 scalar array

items()

keys()

next()

Get the next block from the iterator

pop(name)

Pops off an array by the specified name

save(*args, **kwargs)

Writes this mesh to a file.

to_pandas()

Create a Pandas DataFrame from this Table

update(data)

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 scalar 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 scalar type to search for in the dataset. Must be either 'row' or 'field'.

items()
keys()
property n_arrays
property n_columns
property n_rows
next()

Get the next block from the iterator

pop(name)

Pops off an array by the specified name

property row_arrays

Returns the all row arrays

save(*args, **kwargs)

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

to_pandas()

Create a Pandas DataFrame from this Table

update(data)
values()