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

Question:

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")
Asked By: brown_squirrel

||

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.

Answered By: Archeologist
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.