I would like do display(df)
in a notebook cell. The df
contains a column named 'id' with a string like "A-1234-5678". I would like to avoid the automatic line break on each "-" in the id column and have everything displayed in one line.
I think this happens when the number of columns does not fit the display width and a scrollbar is introduced. This effect does not happen with a "." instead of "-" as shown below:
import pandas as pd
df = pd.DataFrame({'id':["A-123456-7894", "B-123456-7894"]})
for i in range(0, 5):
df[str(i)] = None
display(df)
for i in range(5, 20):
df[str(i)] = None
display(df)
produces
The suggestion to set pd.set_option('display.max_colwidth', -1)
does not resolve my issue.