Print output of all statements in a single cell for jupyter notebook
- Ronak Agrawal
- Jun 19, 2023
- 1 min read
Updated: Nov 20, 2024

If you work with jupyter notebooks, you know it prints/displays only the output of the last statement.
An example is given below
Default jupyter behaviour
Note that, it does not print the output of df.head()` it only prints the output of df.tail(1)
If you execute the following statements in a cell, you should be able to see the output of all statements one after another. It should save a lot of scrolling.
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
Updated jupyter behavior
Comments