[问题] 字体上色却无法显示?哪边错了?

楼主: 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