Plotting Unemployment vs. GDP
Solution
countries = [i["id"] for i in wbdata.get_country(display=False)]
print(countries)
Let’s pull the data now. While we could feed the country list, I just wanted to show what countries were in the dataset. Instead, we just feed the indicators with no countries or dates specified and wbdata will pull everything for the indicators.
df = wbdata.get_dataframe(indicators)
df.dropna(inplace=True)
df
Let’s plot GDP Rate versus Unemployment.
sns.jointplot(df["Unemployment"],df["GDP Rate"],kind="hex")
plt.show()
It’s pretty tough to get much out of this because the outliers shrink down the size of the majority of the points. If we use df.describe(), we can get the basic measures of central tendency.
df.describe()
Let’s get the mean and standard deviation from this. Using loc, we can pick a row based on its index label, as so:
print(df.describe().loc["mean"])
print(df.describe().loc["std"])
Challenge
Create a lower and upper bound three standard deviations from the mean for both variable categories.