[問題] 字體上色卻無法顯示?哪邊錯了?
全部的程式碼: https://goo.gl/dxedRp
下為提問的程式碼:
def color_negative_red(val):
color = 'red' if val > 1.2 else 'black'
return 'color: %s' % color
數值大於1.2呈現紅色
def color_negative_yellow(val):
color = 'yellow' if val > 1 else 'black'
return 'color: %s' % color
數值大於1呈現黃色
def color_negative_green(val):
color = 'green' if val > 0.8 else 'black'
return 'color: %s' % color
數值大於0.5呈現綠色
問題如下:
T3 = table[4].dropna(axis=1,how='all')
T3.columns = hdtt3
T3.style.applymap(color_negative_red,
subset=['POWER-DIFFERENCE']).applymap(color_negative_yellow,
subset=['POWER-DIFFERENCE']).applymap(color_negative_green,
subset=['POWER-DIFFERENCE'])
display(T3)
這樣子寫為何無法判斷把字體的顏色呈現出來?哪邊有錯?要怎麼修正?
判斷的定義:
數值大於1.2呈現紅色且數值大於1底色呈現黃色且數值大於0.5呈現綠色;其他為黑色。
我要達到如此效果如右圖連結:https://i.imgur.com/DtsHpBf.jpg

懇請指點<(_ _)>
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.224.49.75
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1515422968.A.441.html
※ 編輯: han999 (36.224.49.75), 01/08/2018 22:50:35