func should take a Series or DataFrame (depending on axis), andreturn an object with the same shape. Must return a DataFrame with identical index and column labels when axis=None
axis : int, str orNone
apply to each column (axis=0or'index') or to each row (axis=1or'columns') or to the entire DataFrame at once with axis=None
subset : IndexSlice
a valid indexer to limit data to before applying the function. Consider using a pandas.IndexSlice
kwargs : dict
pass along to func
Returns:
self : Styler
比方说我们要对最大的一个值高亮。那么怎么处理呢? 首先定一个函数
1
2
defhighlight_max(x):
return ['background-color: yellow'if v == x.max() else''for v in x]