Workaround to write(unsafe_allow_html=True)?

Hello, I am trying to show a dataframe in a decent format, but the unsafe_allow_html option in the st.write function is disabled, hence I am not able to render a proper dataframe in streamlit for snowflake.

Column configs is not available neither, for the moment.

Is there a workaround to allow styling/formatting dataframes? It’s an essential component of streamlit.

Hi @Ricardo_Picatoste

Perhaps you can try the Pandas styling to highlight certain aspects of the DataFrame?

More info in this related post:

Hope this helps!

Thanks for the suggestion @dataprofessor . The real problem is that some tables really need the multilevel feature for the columns to show data in the proper way, and it’s not supported by st.dataframe (hence is not only applying formatting). to_html allows to show the table in a way that makes the data shown much clearer.

Could html be rendered without allow_unsafe_html=True? It’s really simple html code… that coming from a dataframe.to_html. Or maybe is there other way to achieve the same?

Hi @Ricardo_Picatoste

Aside from the allow_unsafe_html=True parameter, another approach is to use the components.html method to display HTML code.

There are some code snippets here:

Thanks for the suggestion, @dataprofessor . In fact I tried already, but the rendering with this function looks pretty bad even with style applied… so bad that I don’t think I can make it public.

I removed the multilevel columns and used st.dataframe, but so much is list by not having that multiindex that it’s a pity.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.