How to centre and change font colour of pandas dataframe caption?

Viewed 52

enter image description hereHow do I centre the caption of my d15N_model dataframe and make the caption font black instead of grey using pandas .style.set_caption() styler function?

d15N_model = d15N_model.style.set_caption("d15N Model Fixed Effect Statistics")
1 Answers

You can create a dictionary of your preferred caption style:

Styles = [dict(selector = "caption", 
               props = [("color", "black"), 
                        ("text-align", "center")])]

Then set these Styles in set_table_styles:

d15N_model = d15N_model.style.set_caption("d15N Model Fixed Effect Statistics").set_table_styles(Styles)

PS you can set other HTML properties such as background-color, font-size and font-family.

Related