News

New paper! in the American Naturalist

Monday, March 2, 2020

Show pandas dataframe with a colored background



axis=None in .background_gradient is a newer feature. If it doesn't work, upgrade pandas by pip3 install --upgrade pandas.
import pandas as pd

df = # pd.DataFrame
df.style \
 .background_gradient('coolwarm',axis=None)
 # axis=None: colormap is defined using the values in the entire output
 # axis=0: columnwise, axis=1: rowwise
 .set_precision(2) \
 .set_properties(**{'font-size':'0pt'})