当从熊猫dataframe转换为html时,如何在html中显示完整的(非截断的)数据aframe信息?

时间:2021-10-20 23:01:20

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.

我使用dataframe将熊猫数据aframe转换为html输出。to_html函数。当我将它保存到一个单独的html文件时,该文件显示被截断的输出。

For example, in my TEXT column,

例如,在我的文本列中,

df.head(1) will show

df.head(1)将显示

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.

对于大容量的熊猫dataframe的屏幕友好格式来说,这种呈现是可以的,但是我需要一个html文件,它将显示包含在dataframe中的完整表格数据,也就是说,它将显示后面的文本元素,而不是前面的文本片段。

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.

如何在html版本的信息中显示文本列中的每个元素的完整的、非截断的文本数据?我可以想象html表必须显示长单元格才能显示完整的数据,但据我所知,只能将列宽参数传递到DataFrame中。to_html函数。

2 个解决方案

#1


128  

Set the display.max_colwidth option to -1:

设置显示。max_colwidth选项1:

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

set_option docs

set_option文档

#2


31  

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

id (second argument) can fully show the columns.

id(第二个参数)可以完全显示列。

#1


128  

Set the display.max_colwidth option to -1:

设置显示。max_colwidth选项1:

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

set_option docs

set_option文档

#2


31  

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

id (second argument) can fully show the columns.

id(第二个参数)可以完全显示列。