Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RDKit - Export pandas data frame with mol image

Tags:

pandas

rdkit

I would like to know whether is it possible to export pandas dataframe with molecular image directly in excel file format?

Thanks in advance,

like image 203
B.Gees Avatar asked Oct 17 '25 16:10

B.Gees


1 Answers

In RDKit's PandasTools there is the funktion SaveXlsxFromFrame.

http://www.rdkit.org/Python_Docs/rdkit.Chem.PandasTools-module.html#SaveXlsxFromFrame

XlsxWriter must be installed.

import pandas as pd
from rdkit import Chem
from rdkit.Chem import PandasTools

smiles = ['c1ccccc1', 'c1ccccc1O', 'c1cc(O)ccc1O']
df = pd.DataFrame({'ID':['Benzene', 'Phenol', 'Hydroquinone'], 'SMILES':smiles})

df['Mol Image'] = [Chem.MolFromSmiles(s) for s in df['SMILES']]

PandasTools.SaveXlsxFromFrame(df, 'test.xlsx', molCol='Mol Image')
like image 97
rapelpy Avatar answered Oct 19 '25 10:10

rapelpy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!