问题
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?
回答1:
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.
In [1]:
import pandas as pd
In [2]:
def df_style(val):
return 'font-weight: bold'
In [3]:
summary = pd.DataFrame([[0, 0, 0, 0, 0, ],[1620, 203, 392, 651, 2236]],index=['None','Total'])
summary.style.applymap('font-weight: bold',
subset=pd.IndexSlice[summary.index[summary.index=='Total'], :])
print(summary)
And below is the output:
来源:https://stackoverflow.com/questions/51938245/display-dataframe-values-in-bold-font-in-one-row-only