The World Bank gathers an enormous amount of information about the world and the countries we live in. And that data is free to access from an API or, perhaps a little easier from the WBGAPI Python library.
It’s quite possible to browse for information but there is so much of it that it is probably a good idea to have a reasonable idea of what you are looking for before you start programming.
We are going to take a quick look at what information is available, how we can access it and what we can do with the WBGAPI library to fetch it and analyse it. But first we need to install WBGAPI.
pip install wbgapi
Although if you are a Conda person… well you know what to do.
Then before we start programming we need to import the libraries that we will use: wbgapi, of course, but we will also need pandas and matplotlib for what follows.
import pandas as pd
import matplotlib.pyplot as plt
import wbgapi as wb
A good place to start is by using Python’s help facility. You can do this from the Python command line or in a Jupyter Notebook.
The complete output from help is much longer than this but this shows us some of the information that we can access. We will be using a few of these, starting with sources.
The World Bank keeps tens of thousands of indicators about different aspects of world economies and they are stored in many databases. We see the sources that we can access by running the following:
The WBGAPI library has an
info() method for many of its contents, as we shall see. The image below is just the first few of the databases that are available.
An economy is a country or area for which the World Bank stores data. We get a list using the
info() method, again.
And this is the result:
These are the first few economies and, as you can see most of them are individual countries. The first column is the code for the country of area, then comes the name, next is the code for the region and the last column in the table above classifies the economy as:
- LIC — low income country
- HIC — high income country
- LMC — lower middle income country
- HMC — higher middle income country
The region codes can be found like this:
Continue reading: https://towardsdatascience.com/access-a-world-of-data-with-wbgapi-61849354f769?source=rss—-7f60cf5620c9—4