使用时是否可以更改特定行的文本颜色df.to_markdown()
?
我尝试使用df.style.apply([styles]).to_markdown()
但不起作用,因为它将 df 转换为样式器对象。
代码:
print(labels_data.to_markdown(headers= df.columns, tablefmt="jira", showindex=True))
df 风格的代码:
def row_name(x):
for i in x:
if x.name=='Control':
return ['background: yellow']
else:
return ''
labels_data = count_labels(labels).sort_values('% meets', ascending=False)
labels_data.style.apply(lambda x: ['background: lightgreen'
if (x.name == 'control')
else '' for i in x], axis=1)
我的用例是打印降价以在 jira 中复制粘贴表格(带有样式)。
谢谢