Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPython Notebook display every line output without print

I would like IPython Notebook to display every line output without explicitly using the print command. Example:

a, b, c = 1, 2, 4

a

b

c

would only display 4 in the output cell, but I would like it to display

1

2

4

Is there a way to do this? I would also be able to selectively suppress some lines (by using ;?)

like image 821
B6ka Avatar asked Aug 01 '15 16:08

B6ka


People also ask

How do you print all output in a Jupyter notebook without scrolling?

To prevent scrolling within a single cell output, select the cell and press Shift+O while in command state. It will toggle output for that particular cell. If you want all the cells to display long outputs without scrolling, then go to the Cell tab -> All Outputs -> Toggle Scrolling .

How do you display an entire output in Jupyter notebook?

You can easily force the notebook to show all columns by using the following syntax: pd. You can also use the following syntax to display all of the column names in the DataFrame: print(df.

How do I make line numbers visible in Jupyter notebook?

You can enable row numbers in one code cell by pressing L while the cell is not active. You can enable row numbers in all code cells by pressing Shift + L while no cell is active. If you cannot remember these hotkeys, open the command palette by pressing Control + Shift + P and search for 'line numbers'.

How do you see the output of a cell in Jupyter notebook?

Jupyter Notebook can print the output of each cell just below the cell. When you have a lot of output you can reduce the amount of space it takes up by clicking on the left side panel of the output. This will turn the output into a scrolling window.


1 Answers

The answer is

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

Type that on a cell, run it, and from then on each command will display its own output. source

enter image description here

If you don't want to see the output of a particular command, just end it with ";" source

like image 136
Rub Avatar answered Dec 02 '22 18:12

Rub