我想根据 2-3 个条件为某些行着色:
df
status days_since_claim claim_action
0 Closed 349 days No action
1 Closed 353 days No action
2 Granted 373 days Check account
3 Granted 431 days Account checked
4 Closed 448 days No action
我想根据所有三列填充背景
IE
`backgroud_color: 'green' if 'status' == 'Closed' and claim_action == 'No action'
`backgroud_color: 'red' if 'status' == 'Granted' and claim_action == 'Check account' and 'days_since_claim' > 300`
I tried:
styled = mdf.style.applymap(lambda v: 'background-color: %s' %
'red' if v > 300 else "")
def color_s(df):
for i, row in df.iterrows():
if row['status'] == 'Closed':
.
.
我认为我无法掌握样式如何工作的概念。有人可以用例子解释一下吗?
提前致谢。