How to display full (non-truncated) dataframe information in html when converting from pandas dataframe to html?

265
April 21, 2018, at 7:19 PM

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.

Answer 1

Set the display.max_colwidth option to -1:

pd.set_option('display.max_colwidth', -1)

set_option docs

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

id (second argument) can fully show the columns.

READ ALSO
Python writing int into file

Python writing int into file

I have a problem with python code and i don't know what to do, because im fairly new in it

173
basic computer software structure [on hold]

basic computer software structure [on hold]

I recently need to run some crawl program and chatbot on the server(i chouse EC2), but the problem is the programe will shut down if I turn off the putty

182
'return' outside function when ive checked it multiple times?

'return' outside function when ive checked it multiple times?

I need to multiply three arrays and find all possible combinations for an x-ray plot, but no matter what i do it keeps saying 'return' outside function

143