style pandas dataframe code example
Example 1: dataframe format style
df.style.format("{:.2f}")
Example 2: pandas dataframe caption
styles = [dict(selector="caption",
props=[("text-align", "center"),
("font-size", "120%"),
("color", 'black')])] # the color value can not be None
# ...
output += df.style.set_table_attributes("style='display:inline; font-size:110%' ")
.set_caption(caption)
.set_table_styles(styles) # include styles
._repr_html_()