Replies: 1 comment 1 reply
-
|
Hi @jrkarki, sorry for the extremely slow reply. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I am trying to export my dataframe that contains rdchem.Mol.obj (mol structures) in 3 columns into an .xlsx file. I have followed the instructions from following links and it works fine if I am doing it for just one column.
1 http://rdkit.org/docs/source/rdkit.Chem.PandasTools.html#rdkit.Chem.PandasTools.SaveXlsxFromFrame
2. https://stackoverflow.com/questions/51356324/rdkit-export-pandas-data-frame-with-mol-image
What I did to write and export one column (Works):
import xlsxwriter
from rdkit.Chem import PandasTools
from rdkit import Chem
df = sample_data.xlsx
#Code where I convert smiles to Mol and then append it as a new column in df.
df['MCS Structure'] = [Chem.MolFromSmiles(s) for s in df['MCS']]
#write to file
PandasTools.SaveXlsxFromFrame(df,'/ResultsWithImages.xlsx',molCol='MCS Structure',size=[100,100])
The Problem: Doesn't work for multiple columns
What I did to write 3 columns
#create mols for each smile columns
df['Frag Structure'] = [Chem.MolFromSmiles(s) for s in df['Frag']]
df['PDB Ligand Structure'] = [Chem.MolFromSmiles(s) for s in df['PDB_ligand']]
df['MCS Structure'] = [Chem.MolFromSmiles(s) for s in df['MCS']]
#Pass all 3 cols to molCol as above
PandasTools.SaveXlsxFromFrame(df,'/Results_Images_AllCols.xlsx',molCol=['Frag Structure','PDB Ligand Structure','MCS Structure'], size = [100,100])
This throws me an error which is => ValueError: list.remove(x): x not in list. Also see the screenshot.

What I can think of is to append one column at a time to the final xlsx and overwrite it 2 more times. However, I can't find the option to overwrite the file in SaveXlsxFromFrame.
Any hints and suggestions?
Thanks in advance.
Reagon
Beta Was this translation helpful? Give feedback.
All reactions