gpt4 book ai didi

python - 如何更改为背景颜色

转载 作者:行者123 更新时间:2023-11-27 23:10:59 26 4
gpt4 key购买 nike

如何更改背景颜色而不是字体颜色?

def cloud_height_style_function(vals): 
return pd.cut(vals,[-np.inf,199,499,999,3000, np.inf], # need to review the bin a bit
labels=[f'color: {c}' for c in ['#9400D3','#FFA500','#FF0000','#FFFF00','#00b050']])

如果我将标签更改为

    labels=['background-color: %s' for c in ['#9400D3','#FFA500','#FF0000','#FFFF00','#00b050']])

它给了我 ValueError: ('分类类别必须是唯一的', '发生在索引 cld_hgt'

这是我要使用的数据框

    icao msg_type              time    dt  ddd  ff    gg flt_cat   vis  cld_hgt cld_type present_wx vis_obc
0 KLAX ROUTINE 2019-10-14 00:53 1:00 260 10 -9999 VFR 10.0 9999 9999 None -9999
1 KLAX ROUTINE 2019-10-14 01:53 1:00 240 9 -9999 VFR 10.0 9999 9999 None -9999
2 KLAX ROUTINE 2019-10-14 02:53 1:00 260 6 -9999 VFR 10.0 9999 9999 None -9999
3 KLAX ROUTINE 2019-10-14 03:53 1:00 250 5 -9999 VFR 10.0 9999 9999 None -9999
4 KLAX ROUTINE 2019-10-14 04:53 1:00 240 4 -9999 VFR 10.0 9999 9999 None -9999
5 KLAX ROUTINE 2019-10-14 05:53 1:00 250 5 -9999 VFR 10.0 9999 9999 None -9999

这是 Apply Multiple Styles to a data frame specific column 的延续

最佳答案

def cloud_height_style_function(vals): 返回 pd.cut(vals,[-np.inf,199,499,999,3000, np.inf], labels=[f'backngroud-color: {c}' for c in ['#9400D3','#FFA500',' #FF0000','#FFFF00','#00b050']])

关于python - 如何更改为背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58512837/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com