def print_errors(v):
if isinstance(v, int):
if v == 0:
return 'background-color: #ff4c5b;'
elif isinstance(v, str):
if "None" in v or v == "":
return 'background-color: #ff4c5b;'
elif isinstance(v, float):
if v == 0.0:
return 'background-color: #ff4c5b;'
return None
df.style.applymap(print_errors)
# оба экспорта не переносят стили
df.to_excel("result.xlsx", engine="openpyxl")
df.style.to_excel("result.xlsx", engine="openpyxl")
df = df.style.applymap(print_errors)
df.to_excel("result.xlsx")
df.style.applymap(print_errors).to_excel("result.xlsx")