假设我有
df.to_html('table.html', classes='tablecss')
它将输出一个表格:
<table border="1" class="dataframe tablecss">
如何让它只显示“tablecss”而不显示“dataframe tablecss”?
最佳答案
最简单的修复(也许有一个更干净的解决方案):
import re
html_updated = re.sub("class=\"dataframe ", "class=\"", df.head(5).to_html(classes='tablecss'))
with open("table.html", "w") as ouput_file:
ouput_file.write(html_updated)
关于python - 如何使用 df.to_html 删除 "dataframe"类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53012169/