Coloring Cells in Pandas

后端 未结 4 1166
耶瑟儿~
耶瑟儿~ 2020-11-28 10:25

I am able to import data from an excel file using Pandas by using:

xl = read_excel(\'path_to_file.xls\', \'Sheet1\', index_col=None, na_values=[\'NA\'])    
         


        
4条回答
  •  感情败类
    2020-11-28 10:51

    The most simple way is to use applymap and lambda if you only want to highlight certain values:

    df.style.applymap(lambda x: "background-color: red" if x>0 else "background-color: white")
    

提交回复
热议问题