How one can Create Well-Styled Streamlit Dataframes, Part 1: Using the Pandas Styler

-

Streamlit and the pandas Styler object will not be friends. But, we’ll change that!

I even have at all times been a fan of the styler method in pandas. Once I began constructing Streamlit apps, it was clear to me that I desired to style my dataframes to help 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, however the UI display is horrendous!

Because of this I need to share with you my workarounds and concepts to constructing a well-styled dataframe in Streamlit. We are going to cover:

  1. How one can add commas for separating 1000’s in numbers.
  2. How one can display a number as a percentage (from 0.24 in the information to 24% within the UI)
  3. How one can add currency symbols.
  4. How one can add color to the cells. Even higher, I’ll share with you my favourite colour-grading function.
  5. How one can add emojis! Yes, we cant live without emojis 😊!

Streamlit is definitely pretty good at inferring the very best display based on data types. Imagine the…

ASK ANA

What are your thoughts on this topic?
Let us know in the comments below.

0 0 votes
Article Rating
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Share this article

Recent posts

0
Would love your thoughts, please comment.x
()
x