1

Is it possible to change the text color for a specific row when using df.to_markdown()?

I have attempted using df.style.apply([styles]).to_markdown() but does does not work since it converts the df into an styler object.

code:

print(labels_data.to_markdown(headers= df.columns, tablefmt="jira",  showindex=True))

df styled code:


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)

My use case is printing a markdown to copy paste a table (with styles) in jira.

Thanks

David
  • 487
  • 2
  • 6
  • 18

1 Answers1

0

Why not use html? Html is valid inline within markdown, but there isn't a standard way of marking rows within a markdown table (not that markdown is a much of standard, in practice, anyway).

bjw
  • 2,046
  • 18
  • 33