Professional Documents
Culture Documents
FinancialCrisis2009 GH MiniProject WJN
FinancialCrisis2009 GH MiniProject WJN
FinancialCrisis2009 GH MiniProject WJN
Crisis
Gerardo Hernández Galaviz
Dataset(s)
The used dataset was:
https://www.statisticssolutions.com/pearsons-correlation-
coefficient/#:~:text=Pearson's%20correlation%20coefficient%20is%20the,on%20t
he%20method%20of%20covariance.
3/6/2021 FinancialCrisis2009
Do
werewealthier
less countries
impacted in (higher
their GDP
growth per capita)
during the
last financial crisis of 2009?
In [1]: import pandas as pd
import numpy as np
import random
import matplotlib.pyplot as plt
Out[2]: (5656458, 6)
In [3]: #Obtain a data frame with the GDP growth of all countries in 2009
GDPgrowth = data.copy()
filter_GDPgrowth = (GDPgrowth['IndicatorName']=="GDP growth (annual %)") & (GDPg
GDPgrowth = GDPgrowth.loc[filter_GDPgrowth]
In [4]: #Obtain a data frame with the GDP per capita of all countries in 2009
GDP = data.copy()
filter_GDP = (GDP['IndicatorName']=="GDP per capita (current US$)") & (GDP['Year
GDP = GDP.loc[filter_GDP]
In [5]: #Perform a join operation between the 2 dataframes to obtain an equal number of
#per capita
GDPvsGrowth=GDPgrowth.set_index('CountryName').join(GDP.set_index('CountryName')
In [6]: #Do a scatter plot to see the correlation between the 2 variables
#By looking at the graph, one can perceive that higher income countries performe
fig, axis = plt.subplots(figsize=(10, 10))
axis.yaxis.grid(True)
axis.set_title('GDP per capita vs GDP growth in 2009 (financial crisis)',fontsiz
axis.set_xlabel('GDP growth (annual %)',fontsize=12)
axis.set_ylabel('GDP per capita (constant 2005 US$)',fontsize=12)
X = GDPvsGrowth['Value_growth']
Y = GDPvsGrowth['Value_GDP']
axis.scatter(X, Y)
plt.show()
In [8]: #Perform a sort to see which where the countries that had the biggest impact on
#The worst impact was on developing economies in Europe. And the highest increas
GDPvsGrowth.sort_values(by='Value_growth')