Styling pandas in Streamlit

As part of my Streamlit app, I am trying to produce a nicely styled dataframe, formatted to look as nice as possible, to make it easier to be read by human user.
So far, I managed to color the background, do text color formatting based on values, and eliminate the index column from being displayed (it still leaves some empty space in front of the table, but let’s say it is somehow acceptable).
What I haven’t been able to achieve is conditional formatting to decimal places based on value, setting up column widths (ideally I wanted the column to automatically adjust to the maximum length of its content - it’s not very bad how it is now, but still there’s some extra space on each column which could have been eliminated, even manually setting-up width would have been an option), drawing grids (I did manage to color the background, but grids would definitely make the table look nicer), also I was not able to apply any formatting to the column headers.
Initially I opted for a plotly table, but dataframe has the major advantage of being able to sort columns just by clicking on them, it feels much more interactive, instead of a picture produced by plotly table.

What I am looking here is to find out if there problems I encountered are indeed some limitations, or if there are solutions / workarounds for them. Most of the formatting I need for columns is based on the actual values (and not generic applicable for the whole column) and I need someone to advise if I should continue with this implementation or if there are better options for this kind of visualization.

Thanks!

1 Like

Hi there,

Did you ever get an answer to those? Would you mind maybe sharing your code: what you’re describing sound quite good already and the documentation is lacking a bit as this is an experimental feature.

Thanks!