I want to change background color by condition and finally I want to save to excel. There are some cases as follow:
- condition 1: exact match & case sensitive=False --> red
- condition 2: contain & case sensitive=False --> yellow
condition 3: repeat same character 3 more --> blue
list_for_condition1 = [us, ca]
- list_for_condition1 = [apple, sam]
- list_for_condition3 = [xxx, xxxx, xxxxxxxxxxx, bbb, aaa]
I found below code using stype.applymap but couldn't apply this case.
styled = (df.style.applymap(lambda v: 'background-color: %s' % 'green' if v=='col' else ''))
styled.to_excel('d:/temp/styled.xlsx', engine='openpyxl')
How can I solve this?


