0

使用时是否可以更改特定行的文本颜色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 中复制粘贴表格(带有样式)。

谢谢

4

1 回答 1

0

为什么不使用html?Html 在 markdown 中是有效的内联,但是在 markdown 表中没有标记行的标准方法(无论如何,markdown 在实践中并不是很标准)。

于 2020-04-27T19:39:13.800 回答