OliverSherouse / wbdata

A python library for accessing world bank data
GNU General Public License v2.0
182 stars 55 forks source link

Quarterly External Debt Statistics (SDDS) Value error #7

Closed wochner closed 7 years ago

wochner commented 7 years ago

I receive a value error when querying for some of the SDDS External debt data.

indicators = {'DT.DOD.DECT.CD.AR.US': 'Gross external debt'}
df = wbdata.get_dataframe(indicators, convert_date=False)

Traceback (most recent call last): File "F:\source\Python\macro\source_external_debt.py", line 36, in df = wbdata.get_dataframe(indicators, convert_date=False) # load data from worldbank File "", line 2, in get_dataframe File "C:\Python27\lib\site-packages\wbdata\api.py", line 53, in uses_pandas return f(*args, **kwargs) File "C:\Python27\lib\site-packages\wbdata\api.py", line 416, in get_dataframe for i in indicators} File "C:\Python27\lib\site-packages\wbdata\api.py", line 416, in for i in indicators} File "C:\Python27\lib\site-packages\wbdata\api.py", line 167, in get_data data = fetcher.fetch(query_url, args) File "C:\Python27\lib\site-packages\wbdata\fetcher.py", line 163, in fetch raw_response = fetch_url(query_url) File "C:\Python27\lib\site-packages\wbdata\fetcher.py", line 135, in fetch_url raise ValueError ValueError

Other fields (that are very similar) work fine, for example: {'DT.DOD.DECT.CD.GG.AR.US': 'Gross external debt general government'}

OliverSherouse commented 7 years ago

Thanks for this report; I'll investigate.

wochner commented 7 years ago

Hi Oliver,

Thanks for looking into this.

In your other email you also mentioned that I should highlight feature requests. I am relatively new to GitHub. Is there a place for that. Having the IMF API included would be tremendous as both organizations have similar data. As I am also new to python, I have no idea how much effort such an implementation takes. Would also be glad to help, but it will take some time and experience until I am there.

Cheers, Mike

Am 19.01.2017 um 17:29 schrieb Oliver Sherouse notifications@github.com:

Thanks for this report; I'll investigate.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

wochner commented 7 years ago

I have done some more research and looked at Table 2 of the QEDS, because it is rather short. here is a good overview of all the tables.

Most of the data fields on this Table 2 also raise the same ValueError as above:

DT.DOD.DECT.CD.FC.US (0071_T2_Foreign currency 5/) DT.DOD.DSTC.CD.FC.US (0072T2.. Short-term) DT.DOD.DLXF.CD.FC.US (0073T2.. Long-term 6/) DT.DOD.DECT.CD.DC.US (0074_T2_Domestic currency 7/) DT.DOD.DSTC.CD.DC.US (0075T2.. Short-term) DT.DOD.DLXF.CD.DC.US (0076T2.. Long-term) DT.DOD.DECT.CD.UC.US (0077_T2_Unallocated)

Interstingly, the last field and sumtotal of that table works fine:

DT.DOD.DECT.CD.DT.US (0078_T2_Gross External Debt Position)

Even more confusing, as this field should contain the same value as the field DT.DOD.DECT.CD.GG.AR.US (0059_T1_Gross External Debt Position), which I have reported in the original post that does raise a ValueError.

OliverSherouse commented 7 years ago

This seems to be fixed with the switch to the requests backend. Per your question about the IMF, I'll take a look at that as a project for a different library, but I don't know that it makes sense to add it to this particular library.