python里如果输完绿色中文字怎么改变python编译器背景颜色换回黑色?


2023-03-23 14:07:13 发布
我有一个熊猫数据帧,看起来像这样:
ID
CNTS
neg pos neu comp
Overall
1
Reliance Jio Infocomm has accused Bharti Airtel, Vodafone Idea and BSNL of 'cheating' by fraudulently masquerading landline numbers as mobile numbers to unfairly earn interconnect revenue.
0.081
0
0.919
-0.296
Negative
1
The accusation adds new twist to the ongoing telecom tussle.
0.182
0
0.818
-0.25
Negative
1
Here's what is making India's richest man angry.
0.26
0.268
0.472
0.0258
Neutral
2
Jio wants Trai to slap the heaviest penalties on both rivals & BSNL for flouting rules, which it claims cost the company hundreds of crores.
0
0.065
0.935
0.1531
Positive
2
It has also sought a refund of the termination charges it had paid the incumbents due to the alleged fraud. 0.258
0
0.742
-0.7096 Negative
2
Jio claims Airtel, Vodafone Idea and BSNL have implemented a process under which various enterprises are offered mobile numbers as their customer care or helpline numbers. 0
0.118
0.882
0.4939
Positive
我还编写了一个函数,根据dataframe列名“Overall”的值返回特定的颜色:
def cts(val):
if (val == 'Negative'):
color = 'red'
elif (val == "Positive"):
color = 'green'
else:
color = 'black'
return 'color: %s' % color
现在我要做的是,使用颜色,列“CNTS”中的文本应该相应地格式化。你知道吗
我在尝试一些我在熊猫文档网站上读到的东西:
# Apply color
s = df.style.applymap(cts)
s
但这显然是个错误。 但我没有任何线索或想法,如何运用这个功能来实现我想要的。 有人能帮忙吗?你知道吗
Tags: ofthetovalcolorhasnumbersnegativepositivevodafoneoverallcntsjioairtelbsnl

我要回帖

更多关于 怎么改变python编译器背景颜色 的文章

 

随机推荐