1、定位空值
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame(np.random.rand(5,4),columns = list('ABCD'))
df['A'][2] = np.nan
df.style.highlight_null(null_color='red')
2、色彩映射
df = pd.DataFrame(np.random.rand(10,4),columns=['one','two','three','four'])
df.style.background_gradient(cmap='pink',axis =1,low=0,high=1)
# cmap:颜色
# axis:映射参考,0为行,1以列
3、条形图
df = pd.DataFrame(np.random.rand(10,4),columns=['one','two','three','four'])
df.style.bar(subset=['one', 'three'], color='#d65f5f', width=100)
# width:最长长度在格子的占比
4、分段式构建样式
df = pd.DataFrame(np.random.rand(10,4),columns=['one','two','three','four'])
df['one'][[3,2]] = np.nan
df.style.\
bar(subset=['one', 'four'], color='#d65f5f', width=100).\
highlight_null(null_color='yellow')