Suppose I have a dataframe created from the following list:
import pandas as pd
from openpyxl import Workbook
from pandas import ExcelWriter import openpyxl
#Using openpyxl engine
wb = Workbook()
sheet = wb.active
data = [
[0, 0, 1],
[3, 0, 4],
['=EVALUATE(Something ends up being 1)', 0, 4],
[4, 0, 1]]
df = pd.DataFrame(data, columns=["value", "min", "max"])
Now I want to format(color the cell) the first(value) column based on the min and max column; green if within range, and red if not.
In this example it should be [Green,Green,Green,Red].
I've tried a few examples at: https://pandas.pydata.org/pandas-docs/stable/style.html, however, the formatting is static.
Problems:
- If I were to change the value in the excel sheet to fit/unfit the condition, the style remains the same.
- If 1. cannot be addressed, excel formulas are interpreted as non numbers, so how do I get them to evaluate within the code?