Before this is marked as duplicate, I have tried the code from the following topics and none has worked for me thus far:
[Colouring one column of pandas dataframe ]
[Format the color of a cell in a panda dataframe according to multiple conditions ]
[how to color selected columns in python dataframe? ]
I have code that produces three pandas dataframe that looks like this:
RowName Orders Market StartTime StopTime
Status
good A 9 gold 10:00:00 10:09:45
.
.
.
bad B 60 silver 07:54:43 08:02:12
RowName Orders Market StartTime StopTime
Status
good E 19 plat. 10:00:00 10:09:45
.
.
bad F 54 mercury 07:54:43 08:02:12
RowName Orders Market StartTime StopTime
Status
great D 3 alum. 10:00:00 10:09:45
.
.
ok C 70 bronze 07:54:43 08:02:12
where the Status
column is set as the index of each frame
For each frame, I want to highlight the StartTime
column with the value #D42A2A
(aka red) regardless of what value is in a given cell.
How can this be done?
MOST RECENT FAILED ATTEMPTS:
def column_style(col): if col.Name == 'StartTime': return pd.Series('bgcolor: #d42a2a', col.index)
def col_color(data): color = 'red' if data != '' else 'black' return 'color: %s' %color frame.style.applymap(col_color, subset=['StartTime'])
but this also fails.
NOTE:
I am using VI within a linux shell
The entire script is being called by IE (internet explorer) so the output of the script is html
I am using BS (beautifulsoup) to scrape data from a few sites and the aggregating the results onto one page {*after scraping the initial website and creating the required website (call it Page1), I tried to scrape Page1 in the same script and add in the html lines via the
.attrs
method, but this "fails", i.e. the webserver times out during the run}