Python:如何突出显示标题行

Python:如何突出显示标题行,python,pandas,formatting,highlight,Python,Pandas,Formatting,Highlight,以下是突出显示“我的表”中所有行的函数: def highlight(s): if s.Points == 10 or s.Points == 15: return ['background-color : #d9ead3']*3 elif s.Points == 8 or s.Points == 6: return ['background-color : #cfe2f3']*3 elif s.Points == 5: return ['background-colo

以下是突出显示“我的表”中所有行的函数:

def highlight(s): 
if s.Points == 10 or s.Points == 15:
    return ['background-color : #d9ead3']*3
elif s.Points == 8 or s.Points == 6:
    return ['background-color : #cfe2f3']*3
elif s.Points == 5:
    return ['background-color : #f4cccc']*3
elif s.Points == 4:
    return ['background-color : #fff2cc']*3
elif s.Points == 3:
    return ['background-color : #d9d2e9']*3
elif s.Points == 2:
    return ['background-color : #c9daf8']*3
elif s.Points == 1:
    return ['background-color : #ead1dc']*3
else:
    return ['background-color : white']*3
然后我这样调用该函数:

dfnew = df.style.apply(highlight, axis = 1).set_table_styles([{'selector' : '', 
                        'props' : [('border', 
                                    '2px solid black')]}]).set_properties(**{'font-size':'11pt'}) 
我还想突出显示标题行(排名、高尔夫名次、分数)。我该怎么做

我的桌子是这样的:

你试过这个吗

col_loc_1 = df.columns.get_loc('Rank') + 2
col_loc_1 = df.columns.get_loc('GolferName') + 2

df.style.apply(highlight, axis = 1).set_table_styles(
     [{'selector': f'th:nth-child({col_loc_1})',
       'props': [('background-color', '#ff0')]},
     {'selector': f'th:nth-child({col_loc_1})',
       'props': [('background-color', '#00F')]}])