1

I have a block of code that reads in a sql query.

import pandas as pd


Report_results = pd.read_sql_query(Assignment_Query, con=mydb) 

I know this block works, as I can see the data pulled and it is written to an excel file, xlsx to be specific, just fine. What I can't figure out how to do is apply a simple color to the pulled data. I've looked through the pandas documentation and multiple tutorials, but can't seem to get it to work. This is what I tried

Report_results = pd.style.apply(color_negative_red) 

colr_negative_red is simply

def color_negative_red(value):
    color = 'red'
    return 'color: %s' % color

Again, I know that the data is pulled correctly, I just can't figure out how to change the color of the data before it is written to the excel file.

Martin Gergov
  • 1,556
  • 4
  • 20
  • 29
Withdrawnbean
  • 97
  • 1
  • 10

0 Answers0