World Bank

The World Bank is an organization that provides financial advice and helps various nations in terms of their economical state. It also provides a variety of data, including time series, geospatial, financial data, and so on, all of which will be helpful for analysis.

Before we start fetching data from the World Bank website, we must sign up to it. This allows us to get the indicator code for the dataset that we want to download. Signing up for the World Bank is free and doesn't take much time.

For the purpose of this example, I have used the World Development Indicators dataset. You can choose any dataset of your choice and start working on it:

from pandas_datareader import wb  

To get the indicator code, select the Databank tab and choose Metadata Glossary from the list that's displayed on the left-hand pane. You can find the indicator below each dataset, on the left-hand side of the panel (marked in red in the attached screenshot):

 Indicator code for the dataset, which is required for fetching data
dat = wb.download(indicator='FP.CPI.TOTL.ZG', start=2005, end=2019)  

The DataFrame is returned in a multi-index row format:

dat.head()  

This results in the following output:

Multi-indexed DataFrame output of the World Bank indicator data

Now, let's display the data for one particular country, like so:

    dat.loc['Canada']
  

This results in the following output:

Multi-indexed DataFrame output of the World Bank indicator data for one country. It becomes single indexed.

We can also return the price inflation data related to only one particular year for a particular country, like so:

    dat.loc['Canada'].loc['2015']
  

This results in the following output:

 Data subsetted by both indices
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset