Once you add style
to your chained assignments you are operating on a Styler
object. That object has a render
method to get the html as a string. So in your example, you could do something like this:
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()
)
Then include the html
in your email instead of a df.to_html()
.