How can I display full (non-truncated) dataframe information in HTML when converting from Pandas dataframe to HTML? How can I display full (non-truncated) dataframe information in HTML when converting from Pandas dataframe to HTML? python python

How can I display full (non-truncated) dataframe information in HTML when converting from Pandas dataframe to HTML?


Set the display.max_colwidth option to None (or -1 before version 1.0):

pd.set_option('display.max_colwidth', None)

set_option documentation

For example, in IPython, we see that the information is truncated to 50 characters. Anything in excess is ellipsized:

Truncated result

If you set the display.max_colwidth option, the information will be displayed fully:

Non-truncated result


pd.set_option('display.max_columns', None)  

id (second argument) can fully show the columns.


While pd.set_option('display.max_columns', None) sets the number of the maximum columns shown, the option pd.set_option('display.max_colwidth', -1) sets the maximum width of each single field.

For my purposes I wrote a small helper function to fully print huge data frames without affecting the rest of the code. It also reformats float numbers and sets the virtual display width. You may adopt it for your use cases.

def print_full(x):    pd.set_option('display.max_rows', None)    pd.set_option('display.max_columns', None)    pd.set_option('display.width', 2000)    pd.set_option('display.float_format', '{:20,.2f}'.format)    pd.set_option('display.max_colwidth', None)    print(x)    pd.reset_option('display.max_rows')    pd.reset_option('display.max_columns')    pd.reset_option('display.width')    pd.reset_option('display.float_format')    pd.reset_option('display.max_colwidth')