You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to download data from IHME using the "risk" context, I receive an error:
fromddf_utils.factory.ihmeimportIHMELoader# get loader and metadataGBD=IHMELoader()
metadata=GBD.load_metadata()
# choose version: latestversion=metadata['version']['id'].max()
# choose locations: all but 'custom'locations_md=metadata['location']
locations=locations_md[locations_md['id'] !='custom']['id'].tolist()
# download risk datazippath=GBD.bulk_download(
version=version, # which version of the data to useout_dir=outdir, # where to save the datacontext='risk', # GBD nomenclature for 'diseases'age= [2,3,4,5], # early neonatal, late neonatal, postneonatal, 1-4 yearslocation=locations, # all locationssex=3, # both male and femaleyear=2011, # yearmetric=1, # number of casesmeasure= [2,3,4], # daly, yld, yll (no prevalence available)cause= [302, 322], # diarrhea, lower respiratory infectionsrei_id= [136, 137], # non-exclusive breastfeeding, discontinued breastfeedingidsOrNames='both', # include plain text descriptions of the codes in the results file
)
---------------------------------------------------------------------------KeyErrorTraceback (mostrecentcalllast)
~\programs\miniconda\envs\my_notebook\lib\site-packages\pandas\core\indexes\base.pyinget_loc(self, key, method, tolerance)
3079try:
->3080returnself._engine.get_loc(casted_key)
3081exceptKeyErroraserr:
pandas\_libs\index.pyxinpandas._libs.index.IndexEngine.get_loc()
pandas\_libs\index.pyxinpandas._libs.index.IndexEngine.get_loc()
pandas\_libs\hashtable_class_helper.pxiinpandas._libs.hashtable.PyObjectHashTable.get_item()
pandas\_libs\hashtable_class_helper.pxiinpandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'rei_id'Theaboveexceptionwasthedirectcauseofthefollowingexception:
KeyErrorTraceback (mostrecentcalllast)
<ipython-input-6-71661b7cf014>in<module>1# download risk data---->2zippath=GBD.bulk_download(
3version=version, # which version of the data to use4out_dir=outdir, # where to save the data5context='risk', # GBD nomenclature for 'diseases'~\programs\miniconda\envs\my_notebook\lib\site-packages\ddf_utils\factory\ihme.pyinbulk_download(self, out_dir, version, context, **kwargs)
111query= [self._make_query(c, version, **kwargs) forcincontext]
112else:
-->113query= [self._make_query(context, version, **kwargs)]
114115taskIDs=set()
~\programs\miniconda\envs\my_notebook\lib\site-packages\ddf_utils\factory\ihme.pyin_make_query(self, context, version, **kwargs)
225measure=read_opt(kwargs, 'measure', default=measures)
226metric=read_opt(kwargs, 'metric', default=[1, 2, 3])
-->227context_values=rei[rei['type'] ==context]['rei_id'].tolist()
228cause=read_opt(kwargs, 'cause', default=causes)
229queries.update({
~\programs\miniconda\envs\my_notebook\lib\site-packages\pandas\core\frame.pyin__getitem__(self, key)
3022ifself.columns.nlevels>1:
3023returnself._getitem_multilevel(key)
->3024indexer=self.columns.get_loc(key)
3025ifis_integer(indexer):
3026indexer= [indexer]
~\programs\miniconda\envs\my_notebook\lib\site-packages\pandas\core\indexes\base.pyinget_loc(self, key, method, tolerance)
3080returnself._engine.get_loc(casted_key)
3081exceptKeyErroraserr:
->3082raiseKeyError(key) fromerr30833084iftoleranceisnotNone:
KeyError: 'rei_id'
The error occurs because self.metadata['rei'] does not contain a column rei_id. It only contains a column id. Another problem: The current code does not permit users to filter risks. One can only download all risk data at once. My suggestion for a fix: Modfiy line 227 of ihme.py and add an additional line as follows:
context_values=rei[rei['type'] ==context]['id'].tolist() #id instead of rei_idcontext_values=read_opt(kwargs, 'rei_id', default=context_values) # use user-provided ids if given
All the best.
Ben
The text was updated successfully, but these errors were encountered:
Hi Ben, yes, add support for filtering risks is on my to do list but I haven't looked into it yet. I will test your suggestion fix and update the library. Thanks for reporting the issue and providing a solution!
I updated ihme loader as you suggested, but I use rei for the parameter instead of rei_id to make it consistent with the GBD API. The GBD result tool seems very slow to process download queries these days, so I haven't had every thing tested yet.
When trying to download data from IHME using the "risk" context, I receive an error:
The error occurs because
self.metadata['rei']
does not contain a columnrei_id
. It only contains a columnid
. Another problem: The current code does not permit users to filter risks. One can only download all risk data at once. My suggestion for a fix: Modfiy line 227 of ihme.py and add an additional line as follows:All the best.
Ben
The text was updated successfully, but these errors were encountered: