假设我有
df.to_html('table.html', classes='tablecss')
它将输出一个表:
<table border="1" class="dataframe tablecss">
如何使其仅显示“ tablecss”而不显示“ dataframe tablecss”?
答案 0 :(得分:0)
最简单的解决方法(也许有更清洁的解决方案):
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)