Package: world-bank-data
The World Bank Data in PythonThis is an implementation of theWorld Bank API v2in Python. Use this package to explore theWorld Development Indicatorspublished by theWorld Bank.Quick tutorialInstallationInstall or update theWorld Bank Datapython package withpipinstallworld_bank_data--upgradeGet the list of sources, topics, countries, regionsimportpandasaspdimportworld_bank_dataaswbpd.set_option('display.max_rows',6)The list of topics is available withwb.get_topics()Sources are returned bywb.get_sources()And finally, the list of countries is accessible withwb.get_countries()In addition, give a try toget_regionsget_incomelevelsget_lendingtypesto retrieve more information about country classifiers.Get the list of indicatorsThis is done with theget_indicatorsfunction. You may query only the indicators for a specific source or topic as below. If you input no arguments, theget_indicatorfunction will return the description of all the 16,000+ indicators.wb.get_indicators(topic=3,source=2)# topic and source id are from get_topics/get_sourcesRequesting all indicators may take a few seconds, but no worries, the result is cached, so next time this will be instantaneous.Searching for one country or indicatorUse the functionssearch_countries,search_source,search_indicators. Or, if you want to search in a existing dataframe, simply usesearch.wb.search_indicators('mathematics')Get the values of an indicatorThe functionget_seriesreturns the value of a single indicator. The World Bank API accepts quite a few arguments, including:mrv, integer: one or moremost recent valuesdate, string: either one year, or two years separated with a colon, like '2010:2018'gapfill, string: 'Y' or 'N' (the default): forward fills missing values.For instance, the call below returns the most recent estimate for the World Population:wb.get_series('SP.POP.TOTL',mrv=1)The result above has a 3-dimensional index. Use the argumentsimplify_indexto ignore the dimensions that take a single value (here:yearandseries). Also, use the argumentid_or_value='id'if you prefer your data to be indexed by the codes rather than labels:wb.get_series('SP.POP.TOTL',date='2016',id_or_value='id',simplify_index=True)Ready for an interative tutorial?Go to ourBinderand run either thisREADME, or our othertutorialwith the code required to produce this plot of the World Population:ReferencesThe World BankTheWorld Bankhas aData Catalog, and an interactivedata explorer.Third party applications that allow to access the data from various languages are listedhere.Google's Public Data ExplorerThe World Bank data is also available in Google'sData Explorer.PythonAlternatively toworld_bank_data, Python users may find useful the following packages:wbpy, nicely documented but last released in 2013.wbdata, which works well.pandas_datareaderThe reason for which I wroteworld_bank_datais mostly speed, e.g. I wanted to use the lastest version of the World Bank API (v2) and benefit from significant speed improvements. Reimplementing the API also gave me a finer control on the mapping of options.RR users can use two packages to access the World Bank data:WDIwbstatsSee also theIntroduction to the wbstats R-package, or thisquick reviewof the two packages.FAQCountry and indicator description in non-English languagesThe World Bank describes their sources and indicators in other languages than English. Use either thelanguageargument in each ofget_countries,get_indicators, etc, or change the default globally:wb.options.language='vi'wb.get_indicators('SP.POP.TOTL')wb.options.language='en'CachingAll requests, exceptget_series, are cached using aleast recently usedcache from thecachetoolspackage.Using behind a proxyUsing the package behind an http proxy is possible. Use either theproxiesargument in theget_*functins, or set the proxy globally with e.g.:wb.options.proxies={'http':'http://example.com:3128'}LicenseThis python package is licenced under the MIT License.Please also read the World BankTerms of Userelative to the conditions that apply to the data downloaded with this package.