Using pandas .set_properties() and CSS white-space property
My preferred way is to use pandas's pandas.io.formats.style.Styler.set_properties() method and the CSS "white-space": "pre-wrap" property:
from IPython.display import display
# Assuming the variable df contains the relevant DataFrame
display(df.style.set_properties(**{
'white-space': 'pre-wrap',
})
To keep the text left-aligned, you might want to add 'text-align': 'left' as below:
from IPython.display import display
# Assuming the variable df contains the relevant DataFrame
display(df.style.set_properties(**{
'text-align': 'left',
'white-space': 'pre-wrap',
})