-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain-File
154 lines (133 loc) · 7.25 KB
/
Main-File
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
########################################################################################################################################
#Import data from Excel
########################################################################################################################################
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
file='WDIW Dataset.xlsx'
worldData_df=pd.read_excel(file, index_col=0)
#CountryCode = 'CountryCode'
CountryName = 'CountryName'
HultRegion = 'Hult Region'
CoolName = 'Cool Name'
ElectricityAccessTotal = 'ElectricityAccessTotal'
ElectricityRuralAccess = 'ElectricityRuralAccess'
ElectricityUrbanAccess = 'ElectricityUrbanAccess'
AdolescentFertility = 'AdolescentFertility'
AgeDependencyTotal = 'AgeDependencyTotal'
AgeDependencyOld = 'AgeDependencyOld'
AgeDependencyYoung = 'AgeDependencyYoung'
GDP_AgriForFish = 'GDP_AgriForFish'
ArmedForces = 'ArmedForces'
BirthRate = 'BirthRate'
BirthSkilledStaff = 'BirthSkilledStaff'
DeathRate = 'DeathRate'
EducationPHD = 'EducationPHD'
EducationBachelor = 'EducationBachelor'
EducationMaster = 'EducationMaster'
EducationLowerSecondary = 'EducationLowerSecondary'
EducationPostSecondary = 'EducationPostSecondary'
EducationPrimary = 'EducationPrimary'
EducationTertiary = 'EducationTertiary'
EducationUpperSecondary = 'EducationUpperSecondary'
EmploymentAgriculture = 'EmploymentAgriculture'
EmploymentIndustry = 'EmploymentIndustry'
EmploymentServices = 'EmploymentServices'
FertilityRate = 'FertilityRate'
GDP = 'GDP'
GDPGrowth = 'GDPGrowth'
GINI = 'GINI'
ExpendEducation = 'ExpendEducation'
IncomeFourth = 'IncomeFourth'
IncomeFifth = 'IncomeFifth'
IncomeFirst = 'IncomeFirst'
IncomeSecond = 'IncomeSecond'
IncomeThird = 'IncomeThird'
GDP_Industry = 'GDP_Industry'
LifeExpectancy = 'LifeExpectancy'
LiteracyAdult = 'LiteracyAdult'
LiteracyYouth = 'LiteracyYouth'
GDP_Merchandise = 'GDP_Merchandise'
ExpendMilitary = 'ExpendMilitary'
MobileSubs = 'MobileSubs'
PovertyByHealthcare = 'PovertyByHealthcare'
Population0_14 = 'Population0_14'
Population15_64 = 'Population15_64'
Population65 = 'Population65+'
PopulationDensity = 'PopulationDensity'
PopulationGrowth = 'PopulationGrowth'
PopulationLargestCity = 'PopulationLargestCity'
PopulationSlums = 'PopulationSlums'
PopulationFemale = 'PopulationFemale'
PopulationMale = 'PopulationMale'
PopulationTotal = 'PopulationTotal'
Poverty_1 = 'Poverty_1.90'
Poverty_3 = 'Poverty_3.20'
Poverty_NationalLine = 'Poverty_NationalLine'
HIV = 'HIV'
Undernourishment = 'Undernourishment'
Underweight = 'Underweight'
PopulationRural = 'PopulationRural'
GDP_Services = 'GDP_Services'
SurfaceArea = 'SurfaceArea'
TaxRevenue = 'TaxRevenue'
PopulationUrban = 'PopulationUrban'
PopulationUrbanGrowth = 'PopulationUrbanGrowth'
newColumns=[#CountryCode,
CountryName, HultRegion, CoolName, ElectricityAccessTotal, ElectricityRuralAccess,\
ElectricityUrbanAccess, AdolescentFertility, AgeDependencyTotal, AgeDependencyOld, AgeDependencyYoung, GDP_AgriForFish,\
ArmedForces, BirthRate, BirthSkilledStaff, DeathRate, EducationPHD, EducationBachelor, \
EducationMaster, EducationLowerSecondary, EducationPostSecondary, EducationPrimary, EducationTertiary, EducationUpperSecondary,\
EmploymentAgriculture, EmploymentIndustry, EmploymentServices, FertilityRate, GDP, GDPGrowth,\
GINI, ExpendEducation, IncomeFourth, IncomeFifth, IncomeFirst, IncomeSecond,\
IncomeThird, GDP_Industry, LifeExpectancy, LiteracyAdult, LiteracyYouth, GDP_Merchandise,\
ExpendMilitary, MobileSubs, PovertyByHealthcare, Population0_14, Population15_64, Population65,\
PopulationDensity, PopulationGrowth, PopulationLargestCity, PopulationSlums, PopulationFemale, PopulationMale,\
PopulationTotal, Poverty_1, Poverty_3, Poverty_NationalLine, HIV, Undernourishment,\
Underweight, PopulationRural, GDP_Services, SurfaceArea, TaxRevenue, PopulationUrban,\
PopulationUrbanGrowth]
worldData_df.columns = newColumns
teamData_df=worldData_df[worldData_df['Cool Name']=='Skids & Mudflap']
########################################################################################################################################
#Remove Andorra and San Marino
########################################################################################################################################
teamDataCleaned_df=teamData_df.copy()
teamDataCleaned_df=teamDataCleaned_df.drop(labels=['AND','SMR'])
########################################################################################################################################
#Data Exploration
########################################################################################################################################
#Simple describe and comparison with World
print(teamData_df['ElectricityAccessTotal'].describe())
worldData_df['ElectricityAccessTotal'][worldData_df['CountryName']=='World']
#Describe + simple histogram and bar plot
print(teamData_df['GDP_AgriForFish'].describe())
print('\n')
print(worldData_df['GDP_AgriForFish'][worldData_df['CountryName']=='World'])
teamData_df['GDP_AgriForFish']
plt.bar(x=teamData_df.index, height=teamData_df['GDP_AgriForFish'])
plt.xticks(rotation=90)
plt.show()
teamData_df.hist(column=['GDP_AgriForFish'])
plt.show()
#Adding histograms for Western Europe and the Rest of the World
worldData_df['AgeDependencyTotal'][worldData_df['Cool Name']=='Jetfire'].hist()
plt.title('Western Europe')
plt.xlabel('Age Dependency Total')
plt.show()
worldData_df['AgeDependencyTotal'][worldData_df['CountryName']!='World'][worldData_df['Cool Name']!='Skids & Mudflap'].hist()
plt.title('Rest of the World')
plt.xlabel('Age Dependency Total')
plt.show()
########################################################################################################################################
#Correlation
########################################################################################################################################
#Big correlation matrix
correlationData_df=teamData_df.dropna(axis=1, thresh=1).corr().dropna(thresh=1).dropna(axis=1, thresh=1)
f = plt.figure(figsize=(19, 15))
plt.matshow(correlationData_df, fignum=f.number)
plt.xticks(range(correlationData_df.shape[1]), correlationData_df.columns, fontsize=14, rotation=90)
plt.yticks(range(correlationData_df.shape[1]), correlationData_df.columns, fontsize=14)
plt.grid(True)
cb = plt.colorbar()
cb.ax.tick_params(labelsize=14)