having dataframe summary being called directly from jupyter cell
summary #(Shift + Enter)
how can I make the highlighted row only (last row) in bold font?
Please, please provide the code to at least generate the dataframe you are posting.
For what you want, you can use style.applymap() function. The rest is to find the correct properties of font that can be set to bold and how to set index of last row.
import pandas as pd
def df_style(val):
return "font-weight: bold"
summary = pd.DataFrame([[0, 0, 0, 0, 0], [1620, 203, 392, 651, 2236]],
index=["None", "Total"])
# get a handle on the row that starts with `"Total"`, i.e., the last row here
last_row = pd.IndexSlice[summary.index[summary.index == "Total"], :]
# and apply styling to it via the `subset` arg; first arg is styler function above
summaryStyled = summary.style.applymap(df_style, subset=last_row)
display(summaryStyled)
And below is the output:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With