본문 바로가기
프로그램

[파이썬] pandas DataFrame에 Color 적용

by 오디세이99 2022. 10. 4.
728x90
반응형

pandas DataFrame에 style을 사용해서 color를 적용할 수 있습니다.

style.highlight_min()와 style.highlight_max() 를 사용하는 것을 볼 수 있습니다.

1개만 사용할 수 있고, 여러개를 사용 시 계속 붙여서 적용할 수 있습니다.

import pandas as pd

dict_item = {
    'item1': [0, 1, 0, 0],
    'item2': [1, 0, 1, 0],
    'item3': [1, 0, 0, 1]
}
df_item = pd.DataFrame(dict_item)

df_style = df_item.style.highlight_min(axis=0, color='blue').highlight_max(axis=0, color='red')
df_style

 

728x90
반응형

댓글