I converted a pandas dataframe to an html output using the DataFrame.to_html
function. When I save this to a separate html file, the file shows truncated output.
For example, in my TEXT column,
df.head(1)
will show
The film was an excellent effort...
instead of
The film was an excellent effort in deconstructing the complex social sentiments that prevailed during this period.
This rendition is fine in the case of a screen-friendly format of a massive pandas dataframe, but I need an html file that will show complete tabular data contained in the dataframe, that is, something that will show the latter text element rather than the former text snippet.
How would I be able to show the complete, non-truncated text data for each element in my TEXT column in the html version of the information? I would imagine that the html table would have to display long cells to show the complete data, but as far as I understand, only column-width parameters can be passed into the DataFrame.to_html
function.
Set the display.max_colwidth
option to -1
:
pd.set_option('display.max_colwidth', -1)
For example, in iPython, we see that the information is truncated to 50 characters. Anything in excess is ellipsized:
If you set the display.max_colwidth
option, the information will be displayed fully: