一旦添加
style到链式分配中,就可以在一个
Styler对象上进行操作。该对象具有
render将html作为字符串获取的方法。因此,在您的示例中,您可以执行以下操作:
html = ( df.style .format(percent) .applymap(color_negative_red, subset=['col1', 'col2']) .set_properties(**{'font-size': '9pt', 'font-family': 'Calibri'}) .bar(subset=['col4', 'col5'], color='lightblue') .render())然后
html在电子邮件中添加而不是
df.to_html()。



