I am trying to color, highlight, or change fond of Python pandas DataFrame based on the value of the cell. e.g. if the cells on each rows are bigger than the cell in the first column of that row, then highlight the cell as red (or any other color), otherwise leave it as it is.
I wrote a for loop here:
for index in range(0, df.shape[0]):
for column in range(1, df.shape[1]): # from 1 not from 0 because I only need # to compare the 2nd to the last cell of each row with the 1st cell in the row
if df.iloc[index][column] - df_BDE_n_months_avg_std_pct.iloc[index][0] > 0:
then "PLEASE PUT YOUR HELP HERE, I NEED A PIECE OF CODE THAT CAN HIGHLIGHT THE CELL"
else:
"DO NOTHING"
So far I haven't found a way to do it. Any help will be great.