Я пытаюсь создать код, который будет извлекать данные из фрейма данных, применять определенные заголовки и удалять избыточные, после чего использовать данные, которые должны быть помещены под заголовками, которые мне нужны, чтобы заполнить пробелы сплошным цветом вЧтобы выделить их для анализа, а затем экспортировать в новый файл Excel для его распространения.
Я попробовал применить цвет, я определил цвет и попытался отформатировать в CSS, проблема в том, что, хотя кажется, что формат применяется в IDE, он не переводится в экспортированный файл Excel.
import pandas as pd
from pandas.io.formats.style import Styler
import xlsxwriter
from io import BytesIO
from flask import Flask, send_file
emt = pd.read_excel(r'C:\Users\okelly\Python Project\excel input file.xlsx', header=[0,1])# this adds the parameter into the heading allowing a search of it
#this part works
M_cols = [col for col in emt.columns if 'M' in col]
#this identifies all colums wiht M in thier subheading which is a mandoatory heading and seperates it from three other classes of headings
new_data=pd.DataFrame(emt, columns=M_cols)
#this command pulls the data and sets the list m-cols as the headers
#this code hopefully applies a highlight to hte code in order to allow it to be anaslied
def highlight_null(val):
if val == 'none':
color = 'yellow'
else : color = 'white'
return 'background-color: %s' % color
result.style.apply(highlight_null)
result.to_excel('output1.xlsx', engine='xlsxwriter')
кажется, что никаких ошибок не возникает, и он производит файл Excel, но нет форматирования файла