-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeatherDataAnalysis.py
More file actions
223 lines (83 loc) · 2.6 KB
/
WeatherDataAnalysis.py
File metadata and controls
223 lines (83 loc) · 2.6 KB
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
#!/usr/bin/env python
# coding: utf-8
# # Weather Data Analysis using python
# In[6]:
import pandas as pd
# In[12]:
data = pd.read_csv("E:\Weather Data.csv")
# In[17]:
data.head()
# In[19]:
data.index
# In[18]:
data.shape
# In[21]:
data.columns
# In[23]:
data.dtypes
# In[27]:
data['Weather'].unique()
# In[32]:
data.count()
# In[28]:
data.nunique()
# In[33]:
data['Weather'].value_counts()
# In[34]:
data.info()
# # Q.1) Find all the unique 'Wind Speed' values in the data.
# In[35]:
data['Wind Speed_km/h'].unique()
# # Q. 2) Find the number of times when the 'Weather is exactly Clear'.
# In[48]:
data[data['Weather'] == 'Clear'].count()
# # Q. 3) Find the number of times when the 'Wind Speed was exactly 4 km/h'.
# In[53]:
data[data['Wind Speed_km/h'] ==4 ]
# # Q. 4) Find out all the Null Values in the data.
# In[55]:
data.isnull().sum()
# # Q. 5) Rename the column name 'Weather' of the dataframe to 'Weather Condition'.
# In[56]:
data.rename(columns={'Weather': 'Weather Condition'},inplace = True)
# In[57]:
data.head()
# # Q. 6) What is the mean 'Visibility' ?
# In[59]:
data['Visibility_km'].mean()
# # Q. 7) What is the Standard Deviation of 'Pressure' in this data?
# In[61]:
data.Press_kPa.std()
# # Q. 8) What is the Variance of 'Relative Humidity' in this data ?
# In[64]:
data['Rel Hum_%'].var()
# # Q. 9) Find all instances when 'Snow' was recorded.
# In[68]:
data.groupby('Weather Condition').get_group('Snow')
# # Q. 10) Find all instances when 'Wind Speed is above 24' and 'Visibility is 25'.
# In[75]:
data[(data['Wind Speed_km/h'] > 24 ) & (data['Visibility_km'] == 25) ]
# # Q. 11) What is the Mean value of each column against each 'Weather Condition ?
# In[76]:
data.head()
# In[77]:
data.groupby('Weather Condition').mean()
# # Q. 12) What is the Minimum & Maximum value of each column against each 'Weather Condition ?
# In[78]:
data.groupby('Weather Condition').min()
# In[79]:
data.groupby('Weather Condition').max()
# # Q. 13) Show all the Records where Weather Condition is Fog.
# In[80]:
data.groupby('Weather Condition').get_group('Fog')
# # Q. 14) Find all instances when 'Weather is Clear' or 'Visibility is above 40'.
# In[82]:
data[(data['Weather Condition'] == 'Clear') | (data['Visibility_km'] > 40)]
# # Q. 15) Find all instances when :
# A. 'Weather is Clear' and 'Relative Humidity is greater than 50'
# or
# B. 'Visibility is above 40'
# In[83]:
data.head(2)
# In[84]:
data[(data['Weather Condition'] == 'Clear') & (data['Rel Hum_%'] > 50) | (data['Visibility_km']> 40)]