我有一个DateFrame'tsod',现在我把它转换为html:
tsod.to_html()
Run Code Online (Sandbox Code Playgroud)
如何将其保存为文件?最好保存为'.html'文件.
dan*_*van 11
with open('my_file.html', 'w') as fo:
fo.write(tsod.to_html())
Run Code Online (Sandbox Code Playgroud)
或者使用熊猫
tsod.to_html(open('my_file.html', 'w'))
Run Code Online (Sandbox Code Playgroud)
或者再次(谢谢@ andy-hayden)
with open('my_file.html', 'w') as fo:
tsod.to_html(fo)
Run Code Online (Sandbox Code Playgroud)