I have a Microsoft Excel spreadsheet (screenshot) that I'm trying to format using the pandas library in Python, but I can't seem to find any way that I can select only the cells that have a specific colour (blue, for instance). So far, I've tried using both the styleframe and openpyxl library but none have worked for me without any errors.
With styleframe (using this implementation), I believe I can only find specific basic colours that the library supports in its utils module (here). However, my spreadsheet has more advanced colour codes, which styleframe is unable to find, giving me an empty DataFrame as the output.
Empty DataFrame
Columns: []
Index: []
Code:
def find_bs_cs_2021(cell):
return cell if cell.style.bg_color in {utils.colors.dark_yellow, 'FFB740'} else np.nan
def main():
styleframe_dataframe=StyleFrame.read_excel('TimeTable, FSC, Fall-2022.xlsx', sheet_name='Monday', read_style=True, use_openpyxl_styles=False)
find=StyleFrame(styleframe_dataframe.applymap(find_bs_cs_2021).dropna(how='all').dropna(how='all', axis=1))
print(find)
Is there any way to select these cells that styleframe doesn't support, either by using the library or any other library? Eventually, what I want to do is find all the values in the spreadsheet with a specific colour, along with their indexes and column names. I'd highly appreciate any assistance regarding this! :)