Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable line wrapping in Jupyter notebook output cells?

By default longer lines of text in the output cells of a Jupyter notebook will be wrapped. How to stop this behaviour?

like image 448
SomJura Avatar asked Nov 26 '18 13:11

SomJura


1 Answers

If you don't want to mess around with a config file, you can modify the behaviour of a notebook ad hoc by calling the IPython.core.display function. Then add the CSS suggested by @atevm:

from IPython.core.display import display, HTML
display(HTML("<style>div.output_area pre {white-space: pre;}</style>"))

for line in range(5):
    for num in range(70):
        print(f" {num}", end="")
    print()
like image 84
Steve Bond Avatar answered Sep 19 '22 15:09

Steve Bond