##  [PyDPF-Post Cheat Sheet](/blog/pydpf-post-cheat-sheet) 

This is a quick-reference guide for [PyDPF-Post](https://post.docs.pyansys.com/version/stable/). Jump to a section of your choosing with these links:

[Load results file](#load) | [Fetch result metadata](#fetch) | [Access mesh](#mesh) | [Access results](#results) | [Enable autocompletion for result quantities](#autocomplete) | [Plot results](#plot) | [Create and manipulate a dataframe](#dataframe)

# <a name="load"></a>Load results file

Instantiate a simulation object with the path to the results file: On Windows, load the result file: ```python
from ansys.dpf import post
from ansys.dpf.post import examples

sim = post.load_simulation(r'C:\Users\user\file.rst')

```

On Linux, load the result file:

```python
sim = post.load_simulation(r'/home/user/file.rst')

```

# <a name="fetch"></a>Fetch result metadata

Display metadata from the simulation object: ```python
example_path = examples.find_static_rst() 
simulation = post.load_simulation(example_path)
print(simulation)

```

# <a name="mesh"></a>Access mesh

Access the mesh: ```python
mesh = simulation.mesh
print(mesh)

```

# <a name="results"></a>Access results

Get the displacement result: ```python
disp = simulation.displacement()
x_disp = simulation.displacement(components=["X"])
# Extract displacement on specific nodes from already extracted large data set
nodes_disp = disp.select(node_ids=[1, 10, 100])
# Extract displacement on specific nodes from results file
nodes_disp = simulation.displacement(node_ids=[1, 10, 100])

```

Access the stress and strain results:

```python
elem_nodal_stress = simulation.stress()
nodal_stress = simulation.stress_nodal()
elemental_stress = simulation.stress_elemental()
# Extract elemental stresses on specific elements from results file
elemental_stress = simulation.stress_elemental(element_ids=[5, 6, 7])
# Nodal strain
strain = simulation.elastic_strain_nodal()

```

# <a name="autocomplete"></a>Enable autocompletion for result quantities

Postprocess result quantities using a physics-oriented API, which enables auto-completion: Return static simulation results: ```python
simulation = post.StaticMechanicalSimulation(example_path)
print(simulation)
displacement = simulation.displacement()

```

Return modal simulation results:

```python
simulation = post.ModalMechanicalSimulation(example_path)
# Print natural frequencies
print(simulation.time_freq_support)

```

Return transient simulation results and create an animation:

```python
simulation = post.TransientMechanicalSimulation(example_path)
print(simulation)
# Query the displacement vectorial field for all times
displacement = simulation.displacement(all_sets=True)
# Create animation showing the norm of vectorial fields with several components
displacement.animate(deform=True, title="U")

```

Return harmonic simulation results:

```python
simulation = post.HarmonicMechanicalSimulation(example_path)
print(simulation.time_freq_support)
displacement = simulation.displacement(set_ids=[1, 2])
subdisp = displacement.select(complex=0, set_ids=1)
subdisp.plot(title="U tot real")
subdisp = displacement.select(complex=1, set_ids=1)
subdisp.plot(title="U tot imaginary") 

```

# <a name="plot"></a>Plot results

Plot total deformation (norm of the displacement vector field) results: ```python
# Instantiate the solution object
example_path = examples.find_static_rst()
simulation = post.load_simulation(example_path)
displacement_norm = simulation.displacement(norm=True)
# Plot the data and save the image 
displacement_norm.plot(screenshot="total_disp.png")

```

# <a name="dataframe"></a>Create and manipulate a dataframe

Create a DPF dataframe by extracting a result from a simulation, which can be manipulated and viewed differently: ```python
simulation = post.StaticMechanicalSimulation( example_path)
# Extract a result as a dataframe 
displacement_dataframe = simulation.displacement(all_sets=True)

```

Return the dataframe’s column labels:

```python
print(displacement_dataframe.columns)

```

Display the results index:

```python
print(displacement_dataframe.columns.results_index)

```

Display the values available in the index:

```python
print(displacement_dataframe.columns[0].values)

```

Change the number of data rows or columns displayed:

```python
displacement_dataframe.display_max_rows = 9
print(displacement_dataframe)

```

Select specific columns or rows, using index names as arguments for the `DataFrame.select` method and specified lists of values:

```python
disp_X_1 = displacement_dataframe.select(set_ids=[1], node_ids=[4872, 9005], components=["X "] )
print(disp_X_1)

```

Extract displacement data as an array contained in a dataframe:

```python
print(disp_X_1.array)
# Plot a dataframe 
displacement_dataframe.plot()
# Animate a transient dataframe
displacement_dataframe.animate()

```

# References from PyDPF-Post documentation

- [Getting started](https://post.docs.pyansys.com/version/stable/getting_started/index.html)
- [User guide](https://post.docs.pyansys.com/version/stable/user_guide/index.html)
- [Examples](https://post.docs.pyansys.com/version/stable/examples/index.html)
- [API reference](https://post.docs.pyansys.com/version/stable/api/index.html)