1
+ {
2
+ "nbformat" : 4 ,
3
+ "nbformat_minor" : 0 ,
4
+ "metadata" : {
5
+ "colab" : {
6
+ "provenance" : [],
7
+ "authorship_tag" : " ABX9TyNk6XSvi0hTsD/Vl2RRpcwn" ,
8
+ "include_colab_link" : true
9
+ },
10
+ "kernelspec" : {
11
+ "name" : " python3" ,
12
+ "display_name" : " Python 3"
13
+ },
14
+ "language_info" : {
15
+ "name" : " python"
16
+ }
17
+ },
18
+ "cells" : [
19
+ {
20
+ "cell_type" : " markdown" ,
21
+ "metadata" : {
22
+ "id" : " view-in-github" ,
23
+ "colab_type" : " text"
24
+ },
25
+ "source" : [
26
+ " <a href=\" https://colab.research.google.com/github/Sinrez/PythonProjects/blob/main/1_4_3.ipynb\" target=\" _parent\" ><img src=\" https://colab.research.google.com/assets/colab-badge.svg\" alt=\" Open In Colab\" /></a>"
27
+ ]
28
+ },
29
+ {
30
+ "cell_type" : " code" ,
31
+ "execution_count" : 18 ,
32
+ "metadata" : {
33
+ "id" : " rAgWn3WqsH6J"
34
+ },
35
+ "outputs" : [],
36
+ "source" : [
37
+ " import pandas as pd\n " ,
38
+ " import numpy as np"
39
+ ]
40
+ },
41
+ {
42
+ "cell_type" : " code" ,
43
+ "source" : [
44
+ " df_all = pd.read_csv(\" daily_weather_data.csv\" ).set_index('city')\n " ,
45
+ " df_all.head()"
46
+ ],
47
+ "metadata" : {
48
+ "colab" : {
49
+ "base_uri" : " https://localhost:8080/" ,
50
+ "height" : 238
51
+ },
52
+ "id" : " 6VC3CSpfsN-k" ,
53
+ "outputId" : " 2e947e51-ab7b-459f-98b9-20bae6718148"
54
+ },
55
+ "execution_count" : 14 ,
56
+ "outputs" : [
57
+ {
58
+ "output_type" : " execute_result" ,
59
+ "data" : {
60
+ "text/plain" : [
61
+ " date country Latitude Longitude tavg tmin tmax wdir \\\n " ,
62
+ " city \n " ,
63
+ " Sukhumi 21-07-2018 Abkhazia 43.001525 41.023415 23.4 20.9 25.5 329.0 \n " ,
64
+ " Sukhumi 22-07-2018 Abkhazia 43.001525 41.023415 23.5 21.0 25.7 337.0 \n " ,
65
+ " Sukhumi 23-07-2018 Abkhazia 43.001525 41.023415 23.5 21.1 25.5 41.0 \n " ,
66
+ " Sukhumi 24-07-2018 Abkhazia 43.001525 41.023415 24.3 20.8 27.1 10.0 \n " ,
67
+ " Sukhumi 25-07-2018 Abkhazia 43.001525 41.023415 26.5 22.7 30.0 9.0 \n " ,
68
+ " \n " ,
69
+ " wspd pres \n " ,
70
+ " city \n " ,
71
+ " Sukhumi 9.3 1009.6 \n " ,
72
+ " Sukhumi 9.4 1010.0 \n " ,
73
+ " Sukhumi 8.2 1007.7 \n " ,
74
+ " Sukhumi 9.3 1004.4 \n " ,
75
+ " Sukhumi 9.7 1002.0 "
76
+ ],
77
+ "text/html" : [
78
+ " \n " ,
79
+ " <div id=\" df-278d926f-4165-4941-b915-5fb9d31dfd93\" >\n " ,
80
+ " <div class=\" colab-df-container\" >\n " ,
81
+ " <div>\n " ,
82
+ " <style scoped>\n " ,
83
+ " .dataframe tbody tr th:only-of-type {\n " ,
84
+ " vertical-align: middle;\n " ,
85
+ " }\n " ,
86
+ " \n " ,
87
+ " .dataframe tbody tr th {\n " ,
88
+ " vertical-align: top;\n " ,
89
+ " }\n " ,
90
+ " \n " ,
91
+ " .dataframe thead th {\n " ,
92
+ " text-align: right;\n " ,
93
+ " }\n " ,
94
+ " </style>\n " ,
95
+ " <table border=\" 1\" class=\" dataframe\" >\n " ,
96
+ " <thead>\n " ,
97
+ " <tr style=\" text-align: right;\" >\n " ,
98
+ " <th></th>\n " ,
99
+ " <th>date</th>\n " ,
100
+ " <th>country</th>\n " ,
101
+ " <th>Latitude</th>\n " ,
102
+ " <th>Longitude</th>\n " ,
103
+ " <th>tavg</th>\n " ,
104
+ " <th>tmin</th>\n " ,
105
+ " <th>tmax</th>\n " ,
106
+ " <th>wdir</th>\n " ,
107
+ " <th>wspd</th>\n " ,
108
+ " <th>pres</th>\n " ,
109
+ " </tr>\n " ,
110
+ " <tr>\n " ,
111
+ " <th>city</th>\n " ,
112
+ " <th></th>\n " ,
113
+ " <th></th>\n " ,
114
+ " <th></th>\n " ,
115
+ " <th></th>\n " ,
116
+ " <th></th>\n " ,
117
+ " <th></th>\n " ,
118
+ " <th></th>\n " ,
119
+ " <th></th>\n " ,
120
+ " <th></th>\n " ,
121
+ " <th></th>\n " ,
122
+ " </tr>\n " ,
123
+ " </thead>\n " ,
124
+ " <tbody>\n " ,
125
+ " <tr>\n " ,
126
+ " <th>Sukhumi</th>\n " ,
127
+ " <td>21-07-2018</td>\n " ,
128
+ " <td>Abkhazia</td>\n " ,
129
+ " <td>43.001525</td>\n " ,
130
+ " <td>41.023415</td>\n " ,
131
+ " <td>23.4</td>\n " ,
132
+ " <td>20.9</td>\n " ,
133
+ " <td>25.5</td>\n " ,
134
+ " <td>329.0</td>\n " ,
135
+ " <td>9.3</td>\n " ,
136
+ " <td>1009.6</td>\n " ,
137
+ " </tr>\n " ,
138
+ " <tr>\n " ,
139
+ " <th>Sukhumi</th>\n " ,
140
+ " <td>22-07-2018</td>\n " ,
141
+ " <td>Abkhazia</td>\n " ,
142
+ " <td>43.001525</td>\n " ,
143
+ " <td>41.023415</td>\n " ,
144
+ " <td>23.5</td>\n " ,
145
+ " <td>21.0</td>\n " ,
146
+ " <td>25.7</td>\n " ,
147
+ " <td>337.0</td>\n " ,
148
+ " <td>9.4</td>\n " ,
149
+ " <td>1010.0</td>\n " ,
150
+ " </tr>\n " ,
151
+ " <tr>\n " ,
152
+ " <th>Sukhumi</th>\n " ,
153
+ " <td>23-07-2018</td>\n " ,
154
+ " <td>Abkhazia</td>\n " ,
155
+ " <td>43.001525</td>\n " ,
156
+ " <td>41.023415</td>\n " ,
157
+ " <td>23.5</td>\n " ,
158
+ " <td>21.1</td>\n " ,
159
+ " <td>25.5</td>\n " ,
160
+ " <td>41.0</td>\n " ,
161
+ " <td>8.2</td>\n " ,
162
+ " <td>1007.7</td>\n " ,
163
+ " </tr>\n " ,
164
+ " <tr>\n " ,
165
+ " <th>Sukhumi</th>\n " ,
166
+ " <td>24-07-2018</td>\n " ,
167
+ " <td>Abkhazia</td>\n " ,
168
+ " <td>43.001525</td>\n " ,
169
+ " <td>41.023415</td>\n " ,
170
+ " <td>24.3</td>\n " ,
171
+ " <td>20.8</td>\n " ,
172
+ " <td>27.1</td>\n " ,
173
+ " <td>10.0</td>\n " ,
174
+ " <td>9.3</td>\n " ,
175
+ " <td>1004.4</td>\n " ,
176
+ " </tr>\n " ,
177
+ " <tr>\n " ,
178
+ " <th>Sukhumi</th>\n " ,
179
+ " <td>25-07-2018</td>\n " ,
180
+ " <td>Abkhazia</td>\n " ,
181
+ " <td>43.001525</td>\n " ,
182
+ " <td>41.023415</td>\n " ,
183
+ " <td>26.5</td>\n " ,
184
+ " <td>22.7</td>\n " ,
185
+ " <td>30.0</td>\n " ,
186
+ " <td>9.0</td>\n " ,
187
+ " <td>9.7</td>\n " ,
188
+ " <td>1002.0</td>\n " ,
189
+ " </tr>\n " ,
190
+ " </tbody>\n " ,
191
+ " </table>\n " ,
192
+ " </div>\n " ,
193
+ " <button class=\" colab-df-convert\" onclick=\" convertToInteractive('df-278d926f-4165-4941-b915-5fb9d31dfd93')\"\n " ,
194
+ " title=\" Convert this dataframe to an interactive table.\"\n " ,
195
+ " style=\" display:none;\" >\n " ,
196
+ " \n " ,
197
+ " <svg xmlns=\" http://www.w3.org/2000/svg\" height=\" 24px\" viewBox=\" 0 0 24 24\"\n " ,
198
+ " width=\" 24px\" >\n " ,
199
+ " <path d=\" M0 0h24v24H0V0z\" fill=\" none\" />\n " ,
200
+ " <path d=\" M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\" /><path d=\" M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\" />\n " ,
201
+ " </svg>\n " ,
202
+ " </button>\n " ,
203
+ " \n " ,
204
+ " <style>\n " ,
205
+ " .colab-df-container {\n " ,
206
+ " display:flex;\n " ,
207
+ " flex-wrap:wrap;\n " ,
208
+ " gap: 12px;\n " ,
209
+ " }\n " ,
210
+ " \n " ,
211
+ " .colab-df-convert {\n " ,
212
+ " background-color: #E8F0FE;\n " ,
213
+ " border: none;\n " ,
214
+ " border-radius: 50%;\n " ,
215
+ " cursor: pointer;\n " ,
216
+ " display: none;\n " ,
217
+ " fill: #1967D2;\n " ,
218
+ " height: 32px;\n " ,
219
+ " padding: 0 0 0 0;\n " ,
220
+ " width: 32px;\n " ,
221
+ " }\n " ,
222
+ " \n " ,
223
+ " .colab-df-convert:hover {\n " ,
224
+ " background-color: #E2EBFA;\n " ,
225
+ " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n " ,
226
+ " fill: #174EA6;\n " ,
227
+ " }\n " ,
228
+ " \n " ,
229
+ " [theme=dark] .colab-df-convert {\n " ,
230
+ " background-color: #3B4455;\n " ,
231
+ " fill: #D2E3FC;\n " ,
232
+ " }\n " ,
233
+ " \n " ,
234
+ " [theme=dark] .colab-df-convert:hover {\n " ,
235
+ " background-color: #434B5C;\n " ,
236
+ " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n " ,
237
+ " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n " ,
238
+ " fill: #FFFFFF;\n " ,
239
+ " }\n " ,
240
+ " </style>\n " ,
241
+ " \n " ,
242
+ " <script>\n " ,
243
+ " const buttonEl =\n " ,
244
+ " document.querySelector('#df-278d926f-4165-4941-b915-5fb9d31dfd93 button.colab-df-convert');\n " ,
245
+ " buttonEl.style.display =\n " ,
246
+ " google.colab.kernel.accessAllowed ? 'block' : 'none';\n " ,
247
+ " \n " ,
248
+ " async function convertToInteractive(key) {\n " ,
249
+ " const element = document.querySelector('#df-278d926f-4165-4941-b915-5fb9d31dfd93');\n " ,
250
+ " const dataTable =\n " ,
251
+ " await google.colab.kernel.invokeFunction('convertToInteractive',\n " ,
252
+ " [key], {});\n " ,
253
+ " if (!dataTable) return;\n " ,
254
+ " \n " ,
255
+ " const docLinkHtml = 'Like what you see? Visit the ' +\n " ,
256
+ " '<a target=\" _blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n " ,
257
+ " + ' to learn more about interactive tables.';\n " ,
258
+ " element.innerHTML = '';\n " ,
259
+ " dataTable['output_type'] = 'display_data';\n " ,
260
+ " await google.colab.output.renderOutput(dataTable, element);\n " ,
261
+ " const docLink = document.createElement('div');\n " ,
262
+ " docLink.innerHTML = docLinkHtml;\n " ,
263
+ " element.appendChild(docLink);\n " ,
264
+ " }\n " ,
265
+ " </script>\n " ,
266
+ " </div>\n " ,
267
+ " </div>\n " ,
268
+ " "
269
+ ]
270
+ },
271
+ "metadata" : {},
272
+ "execution_count" : 14
273
+ }
274
+ ]
275
+ },
276
+ {
277
+ "cell_type" : " code" ,
278
+ "source" : [
279
+ " # Найдите минимальное значение колонки'tmin' в Helsinki за 2020 год.\n " ,
280
+ " hell = df_all.loc['Helsinki'].astype({'date': np.datetime64})\n " ,
281
+ " hell_2020 = hell[hell['date'].dt.year == 2020]\n " ,
282
+ " \n " ,
283
+ " # Найдите минимальное значение в столбце 'tmin'\n " ,
284
+ " min_tmin = hell_2020['tmin'].min()\n " ,
285
+ " min_tmin"
286
+ ],
287
+ "metadata" : {
288
+ "colab" : {
289
+ "base_uri" : " https://localhost:8080/"
290
+ },
291
+ "id" : " wkFfV0-Itcud" ,
292
+ "outputId" : " 594f2a3b-dd15-44a8-8647-a2362d1f7ceb"
293
+ },
294
+ "execution_count" : 23 ,
295
+ "outputs" : [
296
+ {
297
+ "output_type" : " stream" ,
298
+ "name" : " stderr" ,
299
+ "text" : [
300
+ " <ipython-input-23-21e4b10811c1>:2: UserWarning: Parsing dates in DD/MM/YYYY format when dayfirst=False (the default) was specified. This may lead to inconsistently parsed dates! Specify a format to ensure consistent parsing.\n " ,
301
+ " hell = df_all.loc['Helsinki'].astype({'date': np.datetime64})\n "
302
+ ]
303
+ },
304
+ {
305
+ "output_type" : " execute_result" ,
306
+ "data" : {
307
+ "text/plain" : [
308
+ " -8.6"
309
+ ]
310
+ },
311
+ "metadata" : {},
312
+ "execution_count" : 23
313
+ }
314
+ ]
315
+ }
316
+ ]
317
+ }
0 commit comments