Stop jupyter notebook wrapping cell contents in pandas html table output

If you make a file: ~/.jupyter/custom$ atom custom.css and then put this in it:

.dataframe td {
    white-space: nowrap;
}

Then it will force the cell to show as one line, but then you get a scrolling table.

enter image description here

If you want it to not scroll, then set:

div.output_subarea {
    overflow-x: inherit;
}

and then it'll be as wide as it needs to be:

enter image description here

It's not super pretty, but I'm sure that you can tidy it up if needs be.

I found this very helpful. You'll also need to restart the notebook after you first create the css file for it to register, but from then on you can just refresh the page to see the changes to the css take effect.

This was the notebook that I was testing on.


Building on Ben's answer, but without needing to go into the custom css files, which work differently for juptyter lab.

Just put this in a cell and run it:

%%html
<style>
.dataframe td {
    white-space: nowrap;
}
</style>