首页 > 解决方案 > df.to_html() 中的类方法

问题描述

如何在 df.to_html() 中使用类方法?

我努力了 :

css_class = {'border-width': 'thin'}

df.to_html(index=False,classes=css_class)

我收到一个错误:TypeError: sequence item 1: expected string, dict found

示例数据:

df = DataFrame({'A':[1,1,2,3,5],'B':[3,4,5,6,7]})

我必须把它写进电子邮件。现在输出看起来像:

在此处输入图像描述

如何减小边框宽度并使其成为单行边框/细边框。

df.to_html ()文档没有给出示例。

标签: pythoncsspandas

解决方案


推荐阅读