Streamlit fairly styled dataframes half 1: utilizing the pandas Styler

Streamlit fairly styled dataframes half 1: utilizing the pandas Styler
Streamlit fairly styled dataframes half 1: utilizing the pandas Styler


Streamlit and the pandas Styler object aren’t pals. However, we are going to change that!

I’ve 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 wished to fashion my dataframes to help in visualising dataframes, however… shock! As of the time of writing, Streamlit st.dataframe() doesn’t assist styler objects, solely dataframe objects. Effectively, correction, it does assist them, however the UI show is horrendous!

For this reason I wish to share with you my workarounds and concepts to constructing a well-styled dataframe in Streamlit. We are going to cowl:

  1. add commas for separating 1000’s in numbers.
  2. show a quantity as a share (from 0.24 within the information to 24% within the UI)
  3. add forex symbols.
  4. add color to the cells. Even higher, I’ll share with you my favorite colour-grading perform.
  5. add emojis! Sure, we cant dwell with out emojis 😊!

Streamlit is definitely fairly good at inferring one of the best show primarily based on information sorts. Think about the…

Leave a Reply

Your email address will not be published. Required fields are marked *