When I display a data frame using st.dataframe(), it displays commas as thousand separators, which is undesirable. I removed the thousand separator using the Pandas’s style.format() method, but this causes a performance penalty on the dashboard.
The data frame, let’s say it’s called ‘big_df’, is not small. It’s about 500 rows by 100 columns. It is the output of a cached function decorated with @st.cache_data(). When displaying the unstyled data frame using st.dataframe(), it is quick. However, when I do:
st.dataframe(big_df.style.format(precision=3, thousands= None, decimal=“.”),
use_container_width=True)
Streamlit will become slow. I wonder if there is a way to cache the styled object, or is the actual displaying of the styled object that is slow?
When I tried to use @st.cache_data() on a helper function that returns the style object, it gives this error:
AttributeError: Can’t pickle local object ‘StylerRenderer.init..’
If you have another way to take away the thousand separator, let me know please. It’s not a big deal, but it shows up at fields like zip code or person id numbers. I might have to just show a plain dataframe.
Thanks