Hello Mike,
you could create a function with your if else structure and use apply on
the pandas dataframe. For example, if you have a SMILES column in your df:
def addMol(smiles):
if Chem.MolFromSmiles(smiles) is None:
Etc
return None # or whatever you wish to return when it fails
else:
Etc
return Chem.MolFromSmiles(smiles)
df['RDKitMol']=df.apply(lambda row: addMol(row['SMILES']), axis=1)
Might not be as efficient as the build-in PandasTools though.
Best,
Fio
On Thu, Oct 31, 2019 at 8:07 AM Mike Mazanetz <[email protected]>
wrote:
> Dear RDKit’ers
>
>
>
> I’ve been trying to skip failed molecules in
> PandasTools.AddMoleculeColumnToFrame.
>
>
>
> This is possible if I chuck each row to a different processor, but what I
> really want to do is return a missing row entry.
>
>
>
> Normally I’d go:
>
> If mol is None:
>
> Etc
>
> Else:
>
> Etc
>
>
>
> But Pandas DF’s seem to being playing hard-ball.
>
>
>
> Any thoughts?
>
>
>
> Cheers,
>
> mike
> _______________________________________________
> Rdkit-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss