使用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中复制粘贴一个表(带有样式)
谢谢
为什么不使用html呢?Html在markdown中是有效的内联标记,但在markdown表中没有标记行的标准方法(无论如何,在实践中,markdown并不是很标准)
相关问题 更多 >
编程相关推荐