【问题标题】:Pandas to_html() col_space arg inputs熊猫 to_html() col_space arg 输入
【发布时间】:2020-08-06 18:34:13
【问题描述】:

pandas 在 to_html 方法中允许的 CSS 间距单位中可能的最小列间距参数是什么。例如df.to_html(col_space= '10em') 好像一点效果都没有。

【问题讨论】:

    标签: python html css pandas


    【解决方案1】:

    我发现将 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>""")
    
    

    【讨论】:

      猜你喜欢
      • 2016-01-28
      • 1970-01-01
      • 2019-01-08
      • 2019-06-28
      • 1970-01-01
      • 2020-09-25
      • 2020-04-18
      • 1970-01-01
      • 2016-11-25
      相关资源
      最近更新 更多