-
wbdata 5
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
Lecture1.4
-
Lecture1.5
-
-
Hexbin Plots 7
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
Lecture2.5
-
Lecture2.6
-
Lecture2.7
-
-
Heatmap 5
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
Lecture3.4
-
Lecture3.5
-
-
Boxplot 2
-
Lecture4.1
-
Lecture4.2
-
-
Violin Plot 5
-
Lecture5.1
-
Lecture5.2
-
Lecture5.3
-
Lecture5.4
-
Lecture5.5
-
-
Time Series 2
-
Lecture6.1
-
Lecture6.2
-
-
Pairplot 2
-
Lecture7.1
-
Lecture7.2
-
-
Kernel Density Estimation 3
-
Lecture8.1
-
Lecture8.2
-
Lecture8.3
-
Getting Data
Let’s get an indicator for pollution.
wbdata.search_indicators("CO2 emissions")
indicators["EN.ATM.CO2E.KT"] = "Pollution"
Let’s also get an indicator for inflation.
wbdata.search_indicators("Inflation, consumer")
indicators["FP.CPI.TOTL.ZG"] = "Inflation"
Each country also has a specific country code. Using wbdata.search_countries(), we can find these codes.
wbdata.search_countries("Japan")
wbdata.search_countries("United States")
wbdata.search_countries("Saudi Arabia")
These three countries are the ones we will look at. Let’s create an array.
countries = ["JPN","USA","SAU"]
All that is left is to decide on the dates we want data for. Let’s set it up to get data starting from 1995.
import datetime
dates = (datetime.datetime(1995, 1, 1), datetime.datetime(2017, 1, 1))
Using wbdata.get_dataframe(), we can get the data we need. What we have to feed in arguments are the indicators, the countries and the dates.
df = wbdata.get_dataframe(indicators, country=countries, data_date=dates)
df
If you do not have experience with pandas, this tutorial should be a helpful quick introduction:
10 Minutes to Pandas
Let’s get rid of any cells that are blank by using dropna(). This returns a dataframe with any rows that have blanks dropped. We can give it the argument inplace=True to make it so that we change the dataframe we call it on.
df.dropna(inplace=True)