I have created an excel file from a dataframe that looks like this:
In [215]: import pandas as pd
In [216]: df = pd.DataFrame({"Name": ["A", "B", "C"], "Status": ['y', 'n', 'yy']})
In [217]: df
Out[217]:
Name Status
0 A y
1 B n
2 C yy
How can I set the bg_color for "Name" based on the value of Status? I have tried a couple of options without success:
format1 = workbook.add_format({"bg_color": "#669731"})
format2 = workbook.add_format({"bg_color": "#FFFA22"})
format3 = workbook.add_format({"bg_color": "#A43829"})
Option 1
worksheet.conditional_format("A2",
{"type": "formula",
"criteria": "=ISNUMBER(SEARCH('y', B2))",
"format": format1
}
)
Option 2
worksheet.conditional_format("A2",
{"type": "formula",
"criteria": "=$B$2='y'",
"format": format1
}
)
None of this has given the expected result and when I open the file, I get an error with the following message: unreadable content in the .xlsx
Also it will be good if I could somehow set do this without iterating the dataframe's value.

