How to display rdkit molecules within the dataframe

I’m using the RDkit python packcage which allows to display molecules. I have them within my dataframe. I can see the molecules within jupyter notebooks withon pandas dataframe, but if I run that dataframe with Streamlit using st.write, all I get is html tags.

Example of notebooks output:

Streamlit output:

How can I display those rdkit molecules with streamlit?

Bets wishes,

Hi @Vito, welcome to the Streamlit community!

st.write() takes an optional argument unsafe_allow_html, if you set it to True it might work.


This is not in a dataframe, but alternatively Draw.MolsToGridImage returns PIL that is interpretable by st.image:

mols = [Chem.MolFromSmiles(i) for i in df['smiles']] st.image(Draw.MolsToGridImage(mols))

1 Like