OliverSherouse / wbdata

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

Many indicators not working #16

Closed luciofaso closed 6 years ago

luciofaso commented 6 years ago

I have been testing the wbdata for some time now. It works well with some indicators, such as

{'1.1_ACCESS.ELECTRICITY.TOT': 'Access to Electricity (%)', '4.1.1_TOTAL.ELECTRICITY.OUTPUT': 'Energy Production', 'DAK.INFR.ROD.CR': 'ciccio2', 'SP.POP.TOTL': 'Population', 'SP.URB.TOTL': 'Urban population', 'SP.URB.TOTL.IN.ZS': 'Urban population (%)'}

but it does not work with many others, such as

{'EN.PRD.ELEC.POP.ZS':'energy pro capita', "DAK.INFR.ROD.CR":'infrastructure',
'SI.POV.NGAP':'Poverty Gap (index)', 'SI.POV.GAP2':'Poverty Rate (in % of population)' }

and many others.

The error I get is the following:


TypeError Traceback (most recent call last)

in () 2 3 #grab indicators above for countires above and load into data frame ----> 4 df = wbdata.get_dataframe(indicators, country=countries, convert_date=False) 5 6 #df is "pivoted", pandas' unstack fucntion helps reshape it into something plottable in get_dataframe(indicators, country, data_date, convert_date, keep_levels) /Users/lraso/anaconda/lib/python3.5/site-packages/wbdata/api.py in uses_pandas(f, *args, **kwargs) 51 if not pd: 52 raise ValueError("Pandas must be installed to be used") ---> 53 return f(*args, **kwargs) 54 55 /Users/lraso/anaconda/lib/python3.5/site-packages/wbdata/api.py in get_dataframe(indicators, country, data_date, convert_date, keep_levels) 414 to_df = {indicators[i]: get_data(i, country, data_date, convert_date, 415 pandas=True, keep_levels=keep_levels) --> 416 for i in indicators} 417 return pd.DataFrame(to_df) 418 /Users/lraso/anaconda/lib/python3.5/site-packages/wbdata/api.py in (.0) 414 to_df = {indicators[i]: get_data(i, country, data_date, convert_date, 415 pandas=True, keep_levels=keep_levels) --> 416 for i in indicators} 417 return pd.DataFrame(to_df) 418 /Users/lraso/anaconda/lib/python3.5/site-packages/wbdata/api.py in get_data(indicator, country, data_date, convert_date, pandas, column_name, keep_levels) 165 else: 166 args.append(("date", data_date.strftime("%Y"))) --> 167 data = fetcher.fetch(query_url, args) 168 if convert_date: 169 data = convert_dates_to_datetime(data) /Users/lraso/anaconda/lib/python3.5/site-packages/wbdata/fetcher.py in fetch(query_url, args, cached) 166 if response is None: 167 raise ValueError("Got no response") --> 168 results.extend(response[1]) 169 this_page = response[0]['page'] 170 pages = response[0]['pages'] TypeError: 'NoneType' object is not iterable
OliverSherouse commented 6 years ago

Unfortunately, it appears that the variables you've listed are ones that, while still appearing in the indicators list returned by the API, are actually no longer available, and I don't know how we'd figure that out without requesting every indicator. I will, at the very least, provide a more helpful error, but until I can think of a way to filter these I'm stuck closing this as an upstream problem.

edwardtilley commented 4 years ago

where is a list of wbdata indicator downloads that are working?

I tried downloading all of the NY. indicators and fetcher.py in the api is failing