I have the following script that turns a pandas dataframe into an interactive html table with Plotly:
goals_output_df = pd.read_csv(os.path.join(question_dir, "data/output.csv"))
fig = go.Figure(data=[go.Table(
columnwidth = [15,170,15,35,35],
header=dict(values=['<b>' + x + '</b>' for x in list(goals_output_df.columns)],
# fill_color='#b9e2ff',
line_color='darkslategray',
align='center',
font=dict(color='black', family="Lato", size=20),
height=30
),
cells=dict(values=[goals_output_df[column] for column in goals_output_df.columns],
# fill_color='#e6f2fd',
line_color='darkslategray',
align='left',
font=dict(color='black', family="Lato", size=20),
height=30
))
])
fig.update_layout(
title="<b>Output summary for %s</b>"%question.strip('question'),
font=dict(
family="Lato",
size=18,
color="#000000"))
fig.write_html(os.path.join(question_dir, "results/output.html"))
The table contains a column named "Output" which can have one of three values for each row: "YES", "NO" and "BORDERLINE".
I want to be able to change the color of the text in the "Output" column such that "YES" is green, "NO" is red and "BORDERLINE" is blue.
Any idea how I could do that? Plotly documentation doesn't seem to help.


