Summary
I have a dataframe with backgruond_gradient coloring that works just fine in VSC or Jupyter Notebook, but when I use st.dataframe(…), streamlit applys the cmap but without taking into account the additional arguments. Is there a workaround, og am I misunderstanding something?
Also, a bit off topic, but having multiple dataframes on the streamlit page, is it possible to set a fixed width for index column, so that the st.dataframes are more aligned?
thank you.
Steps to reproduce
Code snippet:
cmap = plt.cm.get_cmap('RdYlGn')
ldf.style.background_gradient(cmap=cmap,vmin=(-0.015),vmax=0.015,axis=None).format('{:.2%}')
st.dataframe(ldf.style.background_gradient(cmap=cmap,vmin=(-0.015),vmax=0.015,axis=None).format('{:.2%}'))
Expected behavior:
if I run ldf in IDE I get (as it is supposed to be):
Actual behavior:
However, when I run streamlit line i get:.
Debug info
- Streamlit version: 1.20.0
- Python version: 3.11.0
- Using Conda 23.1.0
- OS version: MS windows 10, Enterprise, 10.0.19044
- Browser version: Microsoft Edge 112.0.1722.48 (Official build) (64-bit)


