如何在从pandas数据框转换为html时在html中显示完整(非截断)的数据框信息? [英] How to display full (non-truncated) dataframe information in html when converting from pandas dataframe to html?

查看:494
本文介绍了如何在从pandas数据框转换为html时在html中显示完整(非截断)的数据框信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



例如,在我的TEXT列中,

df.head(1)会显示

这部电影非常出色。 ..



而不是

这部电影是解构复杂的社会情绪在这段时间盛行。

这种表现在大型熊猫数据框的屏幕友好格式的情况下很好,但我需要一个html文件,它将显示数据框中包含的完整表格数据,即显示后面的文本元素而不是前面的文本片段的内容。

如何在html版本的信息中为我的TEXT列中的每个元素显示完整的,非截断的文本数据?我会想象,HTML表格将不得不显示长单元格来显示完整的数据,但据我所知,只有列宽参数可以传递到 DataFrame.to_html function。

解决方案将 display.max_colwidth 选项设置为 -1

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

set_option 文档


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)

set_option docs

这篇关于如何在从pandas数据框转换为html时在html中显示完整(非截断)的数据框信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆