-
Notifications
You must be signed in to change notification settings - Fork 0
/
countries.py
313 lines (212 loc) · 7.23 KB
/
countries.py
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
'''
Scatter of Global Surface Temperature of Different Countries
@author: Suyash Shivaji Phatak
Date: 22/05/2020
'''
# Importing Librarires
import pandas as pd
import matplotlib.pyplot as plt; plt.rcdefaults()
# Reading Data From CSV
df = pd.read_csv('datasets/State.csv')
# Renaming the Columns
df.rename(columns={
'dt':'date',
'AverageTemperature':'Temperature',
'AverageTemperatureUncertainty': 'Uncertainty'
}, inplace=True)
# Checking Names of Columns
print('____________________________________________________________')
print('\nCorrected Column Name:\n')
print(df.columns)
# Displaying Small Data
print('____________________________________________________________')
print('Displaying 1st 10 Data:\n')
print(df.head(10))
# Displaying Rows and Columns
print('____________________________________________________________')
print('\n Displaying Rows and Columns:')
print('\n(Rows, Coulmns) : ',df.shape)
# Displaying Information of Data
print('____________________________________________________________')
print('\nInformation of DataSet :\n')
print(df.info())
# Displaying Sum of Null Values
print('____________________________________________________________')
print('\nChecking for Null Values:\n')
print(df.isna().sum())
''' Method for Replacing Null Values'''
# Getting 2 Rows Which Have Null Values
Temp = df['Temperature']
Temp_ut = df['Uncertainty']
# Taking Mean
Temp_mean = Temp.mean()
Tempct_mean = Temp_ut.mean()
# Replacing Null Values with Mean
Temp.fillna(Temp_mean, inplace=True)
Temp_ut.fillna(Tempct_mean, inplace=True)
'''Method End'''
# Displaying Sum of Null Values After Calling Method
print('____________________________________________________________')
print('\nChecking for Null Values After Applying Method of Replacing Null Values with Mean Value:\n')
print(df.isna().sum())
# Displaying all the counts
print('____________________________________________________________')
print('\nDescribing the Dataset:\n')
print(df.describe(include='all'))
# Differenciating Columns by Countries
# Just Uncomment in right place to see individual countries or all
# I Prefer individual because it has larger number of data such that difficult to computer to handle fast
'''1.Brazil Start
is_brazil = df['Country']=='Brazil'
Brazil = df[is_brazil]
print('__________________________________________________________________')
print('\n(Rows, Columns) of Brazil:')
print(Brazil.shape)
# Plotting Graph for Brazil
brazil_dates = Brazil['date']
brazil_temp = Brazil['Temperature']
# Seperating Figures
plt.figure(1)
# Plotting first points
plt.plot(brazil_dates, brazil_temp, 'o', color = 'r',label = 'Scatter')
# Naming the x axis
plt.xlabel('Dates (Currently Not Showable)')
# Naming the y axis
plt.ylabel('Brazil\'s Surface Temperature')
# Giving a title to graph
plt.title('Brazil Surface Air Temperature Scatter')
# Showing the plot
plt.show()
Brazil End'''
'''2.Russia Start
is_russia = df['Country']=='Russia'
Russia = df[is_russia]
print('__________________________________________________________________')
print('\n(Rows, Columns) of Russia:')
print(Russia.shape)
# Plotting Graph for Russia
russia_dates = Russia['date']
russia_temp = Russia['Temperature']
# Seperating Figures
plt.figure(2)
# Plotting first points
plt.plot(russia_dates, russia_temp, '*' , color='b',label = 'Curve')
# Naming the x axis
plt.xlabel('Dates (Currently Not Showable)')
# Naming the y axis
plt.ylabel('Surface Temperature')
# Giving a title to graph
plt.title('Russia Surface Air Temperature Scatter')
# Showing the plot
plt.show()
Russia End'''
'''3.China Start
is_china = df['Country']=='China'
China = df[is_china]
print('__________________________________________________________________')
print('\n(Rows, Columns) of China:')
print(China.shape)
# Plotting Graph for China
china_dates = China['date']
china_temp = China['Temperature']
# Seperating Figures
plt.figure(3)
# Plotting first points
plt.plot(china_dates, china_temp, '+' , color='g',label = 'Scatter')
# Naming the x axis
plt.xlabel('Dates (Currently Not Showable)')
# Naming the y axis
plt.ylabel('Surface Temperature')
# Giving a title to graph
plt.title('China Surface Air Temperature Scatter')
# Showing the plot
plt.show()
China End'''
'''4.India Start
is_india = df['Country']=='India'
India = df[is_india]
print('__________________________________________________________________')
print('\n(Rows, Columns) of India:')
print(India.shape)
# Plotting Graph for India
india_dates = India['date']
india_temp = India['Temperature']
# Seperating Figures
plt.figure(4)
# Plotting first points
plt.plot(india_dates, india_temp, '+' , color='c',label = 'Scatter')
# Naming the x axis
plt.xlabel('Dates (Currently Not Showable)')
# Naming the y axis
plt.ylabel('Surface Temperature')
# Giving a title to graph
plt.title('India Surface Air Temperature Scatter')
# Showing the plot
plt.show()
India End'''
'''5.Australia Start
is_australia = df['Country']=='Australia'
Australia = df[is_australia]
print('__________________________________________________________________')
print('\n(Rows, Columns) of Australia:')
print(Australia.shape)
# Plotting Graph for Australia
australia_dates = Australia['date']
australia_temp = Australia['Temperature']
# Seperating Figures
plt.figure(5)
# Plotting first points
plt.plot(australia_dates, australia_temp, '.' , color='m',label = 'Scatter')
# Naming the x axis
plt.xlabel('Dates (Currently Not Showable)')
# Naming the y axis
plt.ylabel('Surface Temperature')
# Giving a title to graph
plt.title('Australia Surface Air Temperature Scatter')
# Showing the plot
plt.show()
Australia End'''
'''6.United States Start
is_US = df['Country']=='United States'
US = df[is_US]
print('__________________________________________________________________')
print('\n(Rows, Columns) of United States:')
print(US.shape)
# Plotting Graph for US
US_dates = US['date']
US_temp = US['Temperature']
# Seperating Figures
plt.figure(6)
# Plotting first points
plt.plot(US_dates, US_temp, '.' ,color='y',label = 'Scatter')
# Naming the x axis
plt.xlabel('Dates (Currently Not Showable)')
# Naming the y axis
plt.ylabel('Surface Temperature')
# Giving a title to graph
plt.title('United States Surface Air Temperature Scatter')
# Showing the plot
plt.show()
United States End'''
'''7.Canada Start
is_canada = df['Country']=='Canada'
Canada = df[is_canada]
print('__________________________________________________________________')
print('\n(Rows, Columns) of Canada:')
print(Canada.shape)
# Plotting Graph for Canada
canada_dates = Canada['date']
canada_temp = Canada['Temperature']
# Seperating Figures
plt.figure(7)
# Plotting first points
plt.plot(canada_dates, canada_temp, '.' , color='k',label = 'Scatter')
# Naming the x axis
plt.xlabel('Dates (Currently Not Showable)')
# Naming the y axis
plt.ylabel('Surface Temperature')
# Giving a title to graph
plt.title('Canada Surface Air Temperature Scatter')
# Showing the plot
plt.show()
Canada End'''