Some data in Pubchem does not provides compound value while other data source provides. In this case, to_dataframe or to_dict funtion generate error no "compound"
"""
Some substances of pubchem data doesnot provide compound key
for c in self.record['compound']:
if c['id']['type'] == CompoundIdType.STANDARDIZED:
return c['id']['id']['cid']
"""
if 'compound' in self.record:
for c in self.record['compound']:
if c['id']['type'] == CompoundIdType.STANDARDIZED:
return c['id']['id']['cid']
I think it can be fixed with checking whether Substances has a "compound" key in record
example case bug occurres:
pcp.get_substances("65983-31-5", "name")
It return almost 21 substance from pubchem server and 20th substance
Substance(342573178) has no "compound" key in record, therefore it generates errors when you use to_dataframe or to_dict
Some data in Pubchem does not provides compound value while other data source provides. In this case, to_dataframe or to_dict funtion generate error no "compound"
I think it can be fixed with checking whether Substances has a "compound" key in record
example case bug occurres: pcp.get_substances("65983-31-5", "name")
It return almost 21 substance from pubchem server and 20th substance
Substance(342573178) has no "compound" key in record, therefore it generates errors when you use to_dataframe or to_dict