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
반응형
'프로그램' 카테고리의 다른 글
[파이썬] tkinter simpledialog에서 입력한 문자로 수정하기 (0) | 2022.10.14 |
---|---|
[파이썬] train_test_split의 random_state 옵션 (0) | 2022.10.09 |
[파이썬] pandas Dataframe을 이미지로 저장 (0) | 2022.10.04 |
[파이썬] 사용자 정의 함수를 리스트 요소로 사용 ([1,2,myfunc]) (0) | 2022.10.04 |
한줄 문장으로 이미지 자동으로 만들자(Stable Diffusion) (1) | 2022.10.04 |
댓글