DataSetAttributes.to_pandas#
- DataSetAttributes.to_pandas() pandas.DataFrame[source]#
Return this attribute set as a
pandas.DataFrame.Each array becomes a column. Multi-component arrays are expanded to one column per component, named
{array_name}_{i}. Onlypoint_dataandcell_datacan be converted.field_dataraisesValueError.Requires
pandas.- Returns:
pandas.DataFrameDataFrame with one column per (expanded) array and
valid_array_lenrows.
Notes#
Pandas consolidates the dict of columns into internal blocks
during construction, which copies the data. The returned
DataFrame is effectively a snapshot and does not share memory
with VTK. Callers that need zero-copy access should use
to_arrow() instead.
Examples#
Download Python source code | Download Jupyter notebook
>>> import pyvista as pv
>>> mesh = pv.Cube()
>>> mesh.clear_data()
>>> mesh.point_data['scalars'] = range(mesh.n_points)
>>> df = mesh.point_data.to_pandas()
>>> list(df.columns)
['scalars']