I have always been a fan of the styler method in pandas. When I started building Streamlit apps, it was clear to me that I wanted to style my dataframes to aid in visualising dataframes, but… surprise! As of the time of writing, Streamlit st.dataframe() doesn’t support styler objects, only dataframe objects. Well, correction, it does support them, but the UI display is horrendous!
This is why I want to share with you my workarounds and ideas to building a well-styled dataframe in Streamlit. We will cover:
- How to add commas for separating thousands in numbers.
- How to display a number as a percentage (from 0.24 in the data to 24% in the UI)
- How to add currency symbols.
- How to add colour to the cells. Even better, I will share with you my favourite colour-grading function.
- How to add emojis! Yes, we cant live without emojis 😊!
Streamlit is actually pretty good at inferring the best display based on data types. Imagine the…