[問題] 字體上色卻無法顯示?哪邊錯了?

作者: han999 (鎧材校直定尺切斷機)   2018-01-08 22:49:24
全部的程式碼: 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
懇請指點<(_ _)>

Links booklink

Contact Us: admin [ a t ] ucptt.com