我使用该DataFrame.to_html函数将pandas数据帧转换为html输出.当我将其保存到单独的html文件时,该文件显示截断的输出.
例如,在我的TEXT专栏中,
df.head(1) 将会呈现
这部电影很出色......
代替
这部电影是对解构这一时期普遍存在的复杂社会情绪的极好努力.
在大型熊猫数据帧的屏幕友好格式的情况下,这种表现很好,但我需要一个html文件,它将显示数据框中包含的完整表格数据,即显示后一个文本元素而不是以前的文字片段.
如何在html版本的信息中显示TEXT列中每个元素的完整,非截断的文本数据?我想象html表必须显示长单元格来显示完整的数据,但据我所知,只有列宽参数可以传递给DataFrame.to_html函数.
I have a Python Pandas DataFrame object containing textual data. My problem is, that when I use to_html() function, it truncates the strings in the output.
For example:
import pandas
df = pandas.DataFrame({'text': ['Lorem ipsum dolor sit amet, consectetur adipiscing elit.']})
print (df.to_html())
Run Code Online (Sandbox Code Playgroud)
The output is truncated at adapis...
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>text</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td> Lorem ipsum dolor sit amet, consectetur adipis...</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
There is a related question on …