【发布时间】:2020-08-06 18:34:13
【问题描述】:
pandas 在 to_html 方法中允许的 CSS 间距单位中可能的最小列间距参数是什么。例如df.to_html(col_space= '10em') 好像一点效果都没有。
【问题讨论】:
pandas 在 to_html 方法中允许的 CSS 间距单位中可能的最小列间距参数是什么。例如df.to_html(col_space= '10em') 好像一点效果都没有。
【问题讨论】:
我发现将 CSS 显式放入 HTML 文档会更有效。
with open("formatted.html", "w") as f:
f.write("<h2>Document Name</h2>")
df.to_html(f, escape=False, index=False)
f.write("""<style>
th {text-align: left;}
h2,table {font-family: Arial, Helvetica, sans-serif;}
table {font-size: 0.9em;border-collapse: collapse;}
</style>""")
【讨论】: