How to print all the output of a cell in Jupyter notebook.

Normally, Jupyter notebook only displays the last output of the cell; all others are ignored unless you use the print() function (for Python 3).

For example:

1+2
2+3

Jupyter only displays the following as the output:

5

3, the output for 1+2 gets totally ignored. The simple hack below will fix this.

from IPython.core.interactiveshell import InteractiveShell  InteractiveShell.ast_node_interactivity = "all"

Basically, put the code above in the beginning of your notebook and voilà, all the output is printed.

3
5

Author: Ednalyn C. De Dios

I’ve always been enamored with code and I love data science because of its inherent power to solve real problems. Having grown up in the Philippines, served in the United States Navy, and worked in the nonprofit sector, I am driven to make the world a better place. I have started and participated in numerous campaigns that aim to reduce domestic violence and child abuse in the community.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.