Hi George,
Glad that Greg already helped you getting it working. Just to add some information: The methods RenderImagesInAllDataFrames and ChangeMoleculeRendering are related in their effects but doing slightly different things.
RenderImagesInAllDataFrames is patching the core DataFrame class of pandas to disable the HTML escaping, which is enabled by default in pandas, so this methods affects ALL dataframes. Seeing HTML code in a dataframe is an indicator that something around this pandas patching was not done.The method is called inside AddMoleculeColumnToFrame , but if you do get your molecule objects in another way into your dataframe you would have to call it explicitly. I think this is exactly what was going on in your case.
 
ChangeMoleculeRendering is mainly patching the string representation of molecule objects. But you can pass the dataframe object to this method as well to patch it's HTML escaping, which would affect only this single instance of a dataframe and not all future ones in contrast to RenderImagesInAllDataFrames.
 
Just as a side note: The reason that AddMoleculeColumnToFrame patches the general pandas behaviour is that many dataframe methods (like head, tail,...) return new dataframe instances that would not inherit the HTML escaping if this was only patched for the single dataframe object.
 
Cheers,
Niko
 
 
On October 25, 2013 at 5:31 PM George Papadatos <[email protected]> wrote:

It worked! Many thanks! 
g


On 25 October 2013 16:18, Greg Landrum <[email protected]> wrote:
Hi George,
 
Nikolas is really the expert here, but this just worked for me:
 
curs.execute('select molregno,mol_send(m) from rdk.mols where m@>%s',('c1cccc2c1nncc2',))
d = curs.fetchall()
df2 = pd.DataFrame(d,columns=('molregno','pkl'))
df2['romol']=df2.apply(lambda x:Chem.Mol(str(x['pkl'])),axis=1)
PandasTools.RenderImagesInAllDataFrames()
del df2['pkl']
df2.head(2)
 
-greg
 


On Fri, Oct 25, 2013 at 4:43 PM, George Papadatos <[email protected]> wrote:
Question to rdkit pandas users (pandaskitters?):
 
I managed to have the mol_send(m) object in a pandas frame:
Inline images 1
if I do this: data['mol'].map(str).map(Chem.Mol)
I get the mol in base64 PNG:
 
Inline images 2
 
How do I display the column as rendered images (and keep them internally as a Series of rdmols) ?
 
PandasTools.ChangeMoleculeRendering seems relevant but I can't get it to display the mols
 
Cheers,
 
George

 
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to