I asked this question How to apply different conditional format to different rows? that was kindly answered by @davmos
Now I have a new problem, that is add more than two condtions in different datarows!
So I have the following dataframe: 
Where I am highlighting the max values in the coloured rows, but i also want to add other conditions in other rows. For example the minimum value in the 'FORWARD P/E' row
So my code is the following :
def highlight_min(s): try: is_min = s == s.min() return ['background-color: green' if v else '' for v in is_min] except TypeError: pass except KeyError: pass def highlight_max(s): try: is_max = s == s.max() return ['background-color: green' if v else '' for v in is_max] except TypeError: pass except KeyError: pass df.style.apply(highlight_max, axis=1, subset=(['Book Value Per Share (mrq)', 'Diluted EPS (ttm)','EBITDA', 'Gross Profit (ttm)'], df.columns)) My question is how I can use those other conditional formulas in other rows in the same dataset!
Thank you very much :)
https://stackoverflow.com/questions/66619931/how-to-add-more-than-two-formatting-conditions-to-different-row-in-a-dataframe March 14, 2021 at 08:32AM
没有评论:
发表评论