The solution posted by @JohnE looks like the best way.
I would also like to use a format string, and so add a few details here:
import pandas df = pandas.DataFrame({'a' : [1,2,3],'b' : [4,5,6]}) di = {'a' : 'A (J/K*kg)', 'b' : 'B (N/m^2)'} fstr = {di["a"] : '{:6.2f}', di["b"]:'{:5.2e}'} df.rename(columns=di).style.format(fstr)
This, made in a Juptyer laptop, looks perfect and does exactly what I want.

When I tried the same code in the Python tooltip, the stylist does not display.
>>> import pandas >>> df = pandas.DataFrame({'a' : [1,2,3],'b' : [4,5,6]}) >>> di = {'a' : 'A (J/K*kg)', 'b' : 'B (N/m^2)'} >>> fstr = {di["a"] : '{:6.2f}', di["b"]:'{:5.2e}'} >>> df.rename(columns=di).style.format(fstr) <pandas.io.formats.style.Styler object at 0x105812eb8>
EDIT: In interactive mode (not in a Jupyter laptop), HTML formatting is not displayed, and it seems that Pandas does not have a basic ascii output style for tables.
Donna
source share