read_file.style.apply(lambda x: [ ‘background-color:%s’ % ‘red’ if x < y else ‘background-color :%s’ % ‘green’ for x in read_file.language], axis=0 ,inplace=True) print(“done”) read_file.to_excel(‘coloured.xlsx’,engine=’openpyxl’, index=False)
Advertisement
Answer
Use:
JavaScript
x
14
14
1
import openpyxl
2
from openpyxl import load_workbook
3
excel_file = 'color.xlsx'
4
wb = load_workbook(excel_file, data_only = True)
5
sh = wb['Sheet1']
6
7
out = []
8
for row in sh:
9
if row[0].fill.start_color.index == '00000000':
10
out.append([row[i].value for i in range(len(row))])
11
12
pd.DataFrame(out).to_excel('no_red.xlsx')
13
14
color.xlsx:
no_red.xlsx:
More than one column input:
Output: