如何用熊猫df.to_html获得单线边框?

时间:2019-05-05 11:34:23

标签: python html python-3.x pandas

我正在将pandas数据框导出为html中的表格,并导出到Outlook。 该表看起来不错,但双单元格边框不好,我想要一个单线边框,请检查随附的屏幕截图和代码。 enter image description here

df[['Col1','col2']].to_html( header=True, index=False, na_rep='NaN', formatters=None,  sparsify=None, index_names=True, justify=None,  classes=None, notebook=False, border=1, table_id=None)

1 个答案:

答案 0 :(得分:0)

如果必须使用边框,则可以将边框1替换为0。

to_html().replace('border="1"','border="0"')

但是,HTML5不支持border属性。改用CSS。 post非常适合您。