小编use*_*540的帖子

Pandas 数据表转为带有页脚的 html

假设我将以下数据输出为 HTML:

import pandas as pd
d = {'col1': [1, 2], 'col2': [3, 4]}
df = pd.DataFrame(data=d)
df.to_html(index = False, header = "true")
Run Code Online (Sandbox Code Playgroud)

我希望它也能生成页脚信息,例如</tbody>末尾的标签后面的信息。

<tfoot>\n     <th>col1</th>\n      <th>col2</th>\n    </tr>\n  </tfoot>
Run Code Online (Sandbox Code Playgroud)

这里的文档https://pandas.pydata.org/pandas-docs/version/0.23.4/ generated/pandas.DataFrame.to_html.html没有建议页脚选项,所以很好奇是否有解决方法?

许多表是动态生成的,因此硬编码是不可行的。

感谢您的任何建议

html python pandas

6
推荐指数
1
解决办法
1098
查看次数

标签 统计

html ×1

pandas ×1

python ×1