pandas-datareader icon indicating copy to clipboard operation
pandas-datareader copied to clipboard

wb.download country: add option to exclude aggregates

Open data-coder opened this issue 5 years ago • 1 comments

It would be nice if we could pass an option to wb.download country to exclude aggregates. When using 'all' I'm also getting aggregates data like 'Word' and 'Euro area'.

wb.get_countries()['region'].unique()
array(['Latin America & Caribbean ', 'South Asia', 'Aggregates',
       'Sub-Saharan Africa ', 'Europe & Central Asia',
       'Middle East & North Africa', 'East Asia & Pacific',
       'North America'], dtype=object)

Or pease let me know if this is already implemented. I took a loot at https://github.com/pydata/pandas-datareader/blob/master/pandas_datareader/wb.py but coudn't find it.

data-coder avatar Feb 12 '20 11:02 data-coder

My workaround is to take Afghanistan on, since the regions are at the top. It'd be great to avoid this!

raw = wb.download(indicator='SP.POP.TOTL',
                  country='all', start=2016, 
                  end=2016).reset_index()
first_non_agg_ix = raw.index[raw.country == 'Afghanistan'].tolist()[0]
dat = raw.iloc[first_non_agg_ix:]

MaxGhenis avatar Oct 01 '20 07:10 MaxGhenis