tgherzog / wbgapi

Python module that makes using the World Bank's API a lot easier and more intuitive.
MIT License
140 stars 31 forks source link

Custom Dimension Issues db=80 #16

Closed tpike3 closed 3 years ago

tpike3 commented 3 years ago

This is great!

I am running into one issue.

I am trying to call sectors of the Gender Disaggregated Labor Database (db=80) but cannot figure out the syntax as sector is a custom dimension.

For example:

for row in wb.data.fetch('p_M_skl', 'NER', db=80, sector=["BPH"]): # all years print(row)

I should be able to work with any example that pulls the data.

Thanks

tgherzog commented 3 years ago

That would work except that 'NER' is not a recognized country code. How about Norway (NOR) instead?

for row in wb.data.fetch('p_M_skl', 'NOR', db=80, sector='BPH'): # all years
    print(row)

or with Pandas:

wb.data.DataFrame('p_M_skl', 'NOR', sector='BPH', db=80)
tpike3 commented 3 years ago

@tgherzog Thanks. That worked. One comment is NER is Niger and is listed in the 'wb.economics.info(db=80)` and works with other requests. My inference would be there is just no data for Niger so it returns the APIResponseError .

Regardless, thanks very much.

tgherzog commented 3 years ago

One comment is NER is Niger and is listed in the 'wb.economics.info(db=80)` and works with other requests. My inference would be there is just no data for Niger so it returns the APIResponseError .

@tpike3: Niger is in the WDI (db=2, the default), but it's not included in GDLD:

>>> wb.economy.info('NER', db=2)
id    value       region    incomeLevel
----  ----------  --------  -------------
NER   Niger       SSF       LIC
      1 elements
>>> wb.economy.info('NER', db=80)
--error--
tpike3 commented 3 years ago

Ohhh very good to know thanks!