This commit is contained in:
Dmitriy Shishkov 2023-03-01 20:38:03 +03:00
commit 3af1df451c
14 changed files with 742 additions and 0 deletions

2
practice1/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.venv
.~lock*

249
practice1/country_codes.csv Normal file
View File

@ -0,0 +1,249 @@
Afghanistan,AF
Åland Islands,AX
Albania,AL
Algeria,DZ
American Samoa,AS
Andorra,AD
Angola,AO
Anguilla,AI
Antarctica,AQ
Antigua and Barbuda,AG
Argentina,AR
Armenia,AM
Aruba,AW
Australia,AU
Austria,AT
Azerbaijan,AZ
Bahamas,BS
Bahrain,BH
Bangladesh,BD
Barbados,BB
Belarus,BY
Belgium,BE
Belize,BZ
Benin,BJ
Bermuda,BM
Bhutan,BT
"Bolivia, Plurinational State of",BO
"Bonaire, Sint Eustatius and Saba",BQ
Bosnia and Herzegovina,BA
Botswana,BW
Bouvet Island,BV
Brazil,BR
British Indian Ocean Territory,IO
Brunei Darussalam,BN
Bulgaria,BG
Burkina Faso,BF
Burundi,BI
Cambodia,KH
Cameroon,CM
Canada,CA
Cape Verde,CV
Cayman Islands,KY
Central African Republic,CF
Chad,TD
Chile,CL
Shanghai-China,CN
Christmas Island,CX
Cocos (Keeling) Islands,CC
Colombia,CO
Comoros,KM
Congo,CG
"Congo, the Democratic Republic of the",CD
Cook Islands,CK
Costa Rica,CR
Côte d'Ivoire,CI
Croatia,HR
Cuba,CU
Curaçao,CW
Cyprus,CY
Czech Republic,CZ
Denmark,DK
Djibouti,DJ
Dominica,DM
Dominican Republic,DO
Ecuador,EC
Egypt,EG
El Salvador,SV
Equatorial Guinea,GQ
Eritrea,ER
Estonia,EE
Ethiopia,ET
Falkland Islands (Malvinas),FK
Faroe Islands,FO
Fiji,FJ
Finland,FI
France,FR
French Guiana,GF
French Polynesia,PF
French Southern Territories,TF
Gabon,GA
Gambia,GM
Georgia,GE
Germany,DE
Ghana,GH
Gibraltar,GI
Greece,GR
Greenland,GL
Grenada,GD
Guadeloupe,GP
Guam,GU
Guatemala,GT
Guernsey,GG
Guinea,GN
Guinea-Bissau,GW
Guyana,GY
Haiti,HT
Heard Island and McDonald Islands,HM
Holy See (Vatican City State),VA
Honduras,HN
Hong Kong-China,HK
Hungary,HU
Iceland,IS
India,IN
Indonesia,ID
"Iran, Islamic Republic of",IR
Iraq,IQ
Ireland,IE
Isle of Man,IM
Israel,IL
Italy,IT
Jamaica,JM
Japan,JP
Jersey,JE
Jordan,JO
Kazakhstan,KZ
Kenya,KE
Kiribati,KI
"Korea, Democratic People's Republic of",KP
S.Korea,KR
Kuwait,KW
Kyrgyzstan,KG
Lao People's Democratic Republic,LA
Latvia,LV
Lebanon,LB
Lesotho,LS
Liberia,LR
Libya,LY
Liechtenstein,LI
Lithuania,LT
Luxembourg,LU
Macau-China,MO
"Macedonia, the Former Yugoslav Republic of",MK
Madagascar,MG
Malawi,MW
Malaysia,MY
Maldives,MV
Mali,ML
Malta,MT
Marshall Islands,MH
Martinique,MQ
Mauritania,MR
Mauritius,MU
Mayotte,YT
Mexico,MX
"Micronesia, Federated States of",FM
"Moldova, Republic of",MD
Monaco,MC
Mongolia,MN
Montenegro,ME
Montserrat,MS
Morocco,MA
Mozambique,MZ
Myanmar,MM
Namibia,NA
Nauru,NR
Nepal,NP
Netherlands,NL
New Caledonia,NC
New Zealand,NZ
Nicaragua,NI
Niger,NE
Nigeria,NG
Niue,NU
Norfolk Island,NF
Northern Mariana Islands,MP
Norway,NO
Oman,OM
Pakistan,PK
Palau,PW
"Palestine, State of",PS
Panama,PA
Papua New Guinea,PG
Paraguay,PY
Peru,PE
Philippines,PH
Pitcairn,PN
Poland,PL
Portugal,PT
Puerto Rico,PR
Qatar,QA
Réunion,RE
Romania,RO
Russian Federation,RU
Rwanda,RW
Saint Barthélemy,BL
"Saint Helena, Ascension and Tristan da Cunha",SH
Saint Kitts and Nevis,KN
Saint Lucia,LC
Saint Martin (French part),MF
Saint Pierre and Miquelon,PM
Saint Vincent and the Grenadines,VC
Samoa,WS
San Marino,SM
Sao Tome and Principe,ST
Saudi Arabia,SA
Senegal,SN
Serbia,RS
Seychelles,SC
Sierra Leone,SL
Singapore,SG
Sint Maarten (Dutch part),SX
Slovak Republic,SK
Slovenia,SI
Solomon Islands,SB
Somalia,SO
South Africa,ZA
South Georgia and the South Sandwich Islands,GS
South Sudan,SS
Spain,ES
Sri Lanka,LK
Sudan,SD
Suriname,SR
Svalbard and Jan Mayen,SJ
Swaziland,SZ
Sweden,SE
Switzerland,CH
Syrian Arab Republic,SY
Taiwan,TW
Tajikistan,TJ
"Tanzania, United Republic of",TZ
Thailand,TH
Timor-Leste,TL
Togo,TG
Tokelau,TK
Tonga,TO
Trinidad and Tobago,TT
Tunisia,TN
Turkey,TR
Turkmenistan,TM
Turks and Caicos Islands,TC
Tuvalu,TV
Uganda,UG
Ukraine,UA
UAE,AE
UK,UK
USA,US
United States Minor Outlying Islands,UM
Uruguay,UY
Uzbekistan,UZ
Vanuatu,VU
"Venezuela, Bolivarian Republic of",VE
Vietnam,VN
"Virgin Islands, British",VG
"Virgin Islands, U.S.",VI
Wallis and Futuna,WF
Western Sahara,EH
Yemen,YE
Zambia,ZM
Zimbabwe,ZW
1 Afghanistan AF
2 Åland Islands AX
3 Albania AL
4 Algeria DZ
5 American Samoa AS
6 Andorra AD
7 Angola AO
8 Anguilla AI
9 Antarctica AQ
10 Antigua and Barbuda AG
11 Argentina AR
12 Armenia AM
13 Aruba AW
14 Australia AU
15 Austria AT
16 Azerbaijan AZ
17 Bahamas BS
18 Bahrain BH
19 Bangladesh BD
20 Barbados BB
21 Belarus BY
22 Belgium BE
23 Belize BZ
24 Benin BJ
25 Bermuda BM
26 Bhutan BT
27 Bolivia, Plurinational State of BO
28 Bonaire, Sint Eustatius and Saba BQ
29 Bosnia and Herzegovina BA
30 Botswana BW
31 Bouvet Island BV
32 Brazil BR
33 British Indian Ocean Territory IO
34 Brunei Darussalam BN
35 Bulgaria BG
36 Burkina Faso BF
37 Burundi BI
38 Cambodia KH
39 Cameroon CM
40 Canada CA
41 Cape Verde CV
42 Cayman Islands KY
43 Central African Republic CF
44 Chad TD
45 Chile CL
46 Shanghai-China CN
47 Christmas Island CX
48 Cocos (Keeling) Islands CC
49 Colombia CO
50 Comoros KM
51 Congo CG
52 Congo, the Democratic Republic of the CD
53 Cook Islands CK
54 Costa Rica CR
55 Côte d'Ivoire CI
56 Croatia HR
57 Cuba CU
58 Curaçao CW
59 Cyprus CY
60 Czech Republic CZ
61 Denmark DK
62 Djibouti DJ
63 Dominica DM
64 Dominican Republic DO
65 Ecuador EC
66 Egypt EG
67 El Salvador SV
68 Equatorial Guinea GQ
69 Eritrea ER
70 Estonia EE
71 Ethiopia ET
72 Falkland Islands (Malvinas) FK
73 Faroe Islands FO
74 Fiji FJ
75 Finland FI
76 France FR
77 French Guiana GF
78 French Polynesia PF
79 French Southern Territories TF
80 Gabon GA
81 Gambia GM
82 Georgia GE
83 Germany DE
84 Ghana GH
85 Gibraltar GI
86 Greece GR
87 Greenland GL
88 Grenada GD
89 Guadeloupe GP
90 Guam GU
91 Guatemala GT
92 Guernsey GG
93 Guinea GN
94 Guinea-Bissau GW
95 Guyana GY
96 Haiti HT
97 Heard Island and McDonald Islands HM
98 Holy See (Vatican City State) VA
99 Honduras HN
100 Hong Kong-China HK
101 Hungary HU
102 Iceland IS
103 India IN
104 Indonesia ID
105 Iran, Islamic Republic of IR
106 Iraq IQ
107 Ireland IE
108 Isle of Man IM
109 Israel IL
110 Italy IT
111 Jamaica JM
112 Japan JP
113 Jersey JE
114 Jordan JO
115 Kazakhstan KZ
116 Kenya KE
117 Kiribati KI
118 Korea, Democratic People's Republic of KP
119 S.Korea KR
120 Kuwait KW
121 Kyrgyzstan KG
122 Lao People's Democratic Republic LA
123 Latvia LV
124 Lebanon LB
125 Lesotho LS
126 Liberia LR
127 Libya LY
128 Liechtenstein LI
129 Lithuania LT
130 Luxembourg LU
131 Macau-China MO
132 Macedonia, the Former Yugoslav Republic of MK
133 Madagascar MG
134 Malawi MW
135 Malaysia MY
136 Maldives MV
137 Mali ML
138 Malta MT
139 Marshall Islands MH
140 Martinique MQ
141 Mauritania MR
142 Mauritius MU
143 Mayotte YT
144 Mexico MX
145 Micronesia, Federated States of FM
146 Moldova, Republic of MD
147 Monaco MC
148 Mongolia MN
149 Montenegro ME
150 Montserrat MS
151 Morocco MA
152 Mozambique MZ
153 Myanmar MM
154 Namibia NA
155 Nauru NR
156 Nepal NP
157 Netherlands NL
158 New Caledonia NC
159 New Zealand NZ
160 Nicaragua NI
161 Niger NE
162 Nigeria NG
163 Niue NU
164 Norfolk Island NF
165 Northern Mariana Islands MP
166 Norway NO
167 Oman OM
168 Pakistan PK
169 Palau PW
170 Palestine, State of PS
171 Panama PA
172 Papua New Guinea PG
173 Paraguay PY
174 Peru PE
175 Philippines PH
176 Pitcairn PN
177 Poland PL
178 Portugal PT
179 Puerto Rico PR
180 Qatar QA
181 Réunion RE
182 Romania RO
183 Russian Federation RU
184 Rwanda RW
185 Saint Barthélemy BL
186 Saint Helena, Ascension and Tristan da Cunha SH
187 Saint Kitts and Nevis KN
188 Saint Lucia LC
189 Saint Martin (French part) MF
190 Saint Pierre and Miquelon PM
191 Saint Vincent and the Grenadines VC
192 Samoa WS
193 San Marino SM
194 Sao Tome and Principe ST
195 Saudi Arabia SA
196 Senegal SN
197 Serbia RS
198 Seychelles SC
199 Sierra Leone SL
200 Singapore SG
201 Sint Maarten (Dutch part) SX
202 Slovak Republic SK
203 Slovenia SI
204 Solomon Islands SB
205 Somalia SO
206 South Africa ZA
207 South Georgia and the South Sandwich Islands GS
208 South Sudan SS
209 Spain ES
210 Sri Lanka LK
211 Sudan SD
212 Suriname SR
213 Svalbard and Jan Mayen SJ
214 Swaziland SZ
215 Sweden SE
216 Switzerland CH
217 Syrian Arab Republic SY
218 Taiwan TW
219 Tajikistan TJ
220 Tanzania, United Republic of TZ
221 Thailand TH
222 Timor-Leste TL
223 Togo TG
224 Tokelau TK
225 Tonga TO
226 Trinidad and Tobago TT
227 Tunisia TN
228 Turkey TR
229 Turkmenistan TM
230 Turks and Caicos Islands TC
231 Tuvalu TV
232 Uganda UG
233 Ukraine UA
234 UAE AE
235 UK UK
236 USA US
237 United States Minor Outlying Islands UM
238 Uruguay UY
239 Uzbekistan UZ
240 Vanuatu VU
241 Venezuela, Bolivarian Republic of VE
242 Vietnam VN
243 Virgin Islands, British VG
244 Virgin Islands, U.S. VI
245 Wallis and Futuna WF
246 Western Sahara EH
247 Yemen YE
248 Zambia ZM
249 Zimbabwe ZW

BIN
practice1/initial.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 KiB

287
practice1/main.ipynb Normal file

File diff suppressed because one or more lines are too long

BIN
practice1/output.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

BIN
practice1/output2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

BIN
practice1/output3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

65
practice1/practice1.csv Normal file
View File

@ -0,0 +1,65 @@
UAE,434,442,448
Peru,368,384,373
Ireland,501,523,522
Cyprus,440,449,438
Denmark,500,496,498
Finland,519,524,545
Slovenia,501,481,514
S.Korea,554,536,538
Belgium,515,509,505
New Zealand,500,512,516
Kazakhstan,432,393,425
Switzerland,531,509,515
Indonesia,375,396,382
Australia,504,512,521
Costa Rica,407,441,429
Latvia,491,489,502
Romania,445,438,439
Spain,484,488,496
Portugal,487,488,489
Qatar,376,388,384
Slovak Republic,482,463,471
Jordan,386,399,409
Vietnam,511,508,528
France,495,505,499
Czech Republic,499,493,508
Canada,518,523,525
Malaysia,421,398,420
Israel,466,486,470
Iceland,493,483,478
Japan,536,538,547
Montenegro,410,422,410
Albania,394,394,397
Taiwan,560,523,523
Estonia,521,516,541
Turkey,448,475,463
Luxembourg,490,488,491
Hungary,477,488,494
Austria,506,490,506
Hong Kong-China,561,545,555
Colombia,376,403,399
Russian Federation,482,475,486
Liechtenstein,535,516,525
Argentina,388,396,406
Germany,514,508,524
Italy,485,490,494
Bulgaria,439,436,446
Thailand,427,441,444
Shanghai-China,613,570,580
Lithuania,479,477,496
Brazil,391,410,405
Serbia,449,446,445
USA,481,498,497
Mexico,413,424,415
Singapore,573,542,551
Croatia,471,485,491
UK,494,499,514
Norway,489,504,495
Uruguay,409,411,416
Tunisia,388,404,398
Greece,453,477,467
Macau-China,538,509,521
Sweden,478,483,485
Poland,518,518,526
Chile,423,441,445
Netherlands,523,511,522
1 UAE 434 442 448
2 Peru 368 384 373
3 Ireland 501 523 522
4 Cyprus 440 449 438
5 Denmark 500 496 498
6 Finland 519 524 545
7 Slovenia 501 481 514
8 S.Korea 554 536 538
9 Belgium 515 509 505
10 New Zealand 500 512 516
11 Kazakhstan 432 393 425
12 Switzerland 531 509 515
13 Indonesia 375 396 382
14 Australia 504 512 521
15 Costa Rica 407 441 429
16 Latvia 491 489 502
17 Romania 445 438 439
18 Spain 484 488 496
19 Portugal 487 488 489
20 Qatar 376 388 384
21 Slovak Republic 482 463 471
22 Jordan 386 399 409
23 Vietnam 511 508 528
24 France 495 505 499
25 Czech Republic 499 493 508
26 Canada 518 523 525
27 Malaysia 421 398 420
28 Israel 466 486 470
29 Iceland 493 483 478
30 Japan 536 538 547
31 Montenegro 410 422 410
32 Albania 394 394 397
33 Taiwan 560 523 523
34 Estonia 521 516 541
35 Turkey 448 475 463
36 Luxembourg 490 488 491
37 Hungary 477 488 494
38 Austria 506 490 506
39 Hong Kong-China 561 545 555
40 Colombia 376 403 399
41 Russian Federation 482 475 486
42 Liechtenstein 535 516 525
43 Argentina 388 396 406
44 Germany 514 508 524
45 Italy 485 490 494
46 Bulgaria 439 436 446
47 Thailand 427 441 444
48 Shanghai-China 613 570 580
49 Lithuania 479 477 496
50 Brazil 391 410 405
51 Serbia 449 446 445
52 USA 481 498 497
53 Mexico 413 424 415
54 Singapore 573 542 551
55 Croatia 471 485 491
56 UK 494 499 514
57 Norway 489 504 495
58 Uruguay 409 411 416
59 Tunisia 388 404 398
60 Greece 453 477 467
61 Macau-China 538 509 521
62 Sweden 478 483 485
63 Poland 518 518 526
64 Chile 423 441 445
65 Netherlands 523 511 522

BIN
practice1/practice1.ods Normal file

Binary file not shown.

BIN
practice1/report.odt Normal file

Binary file not shown.

BIN
practice1/report.pdf Normal file

Binary file not shown.

65
practice1/res.csv Normal file
View File

@ -0,0 +1,65 @@
Shanghai-China,613.0,570.0,580.0,CN,587.6666666666666
Singapore,573.0,542.0,551.0,SG,555.3333333333334
Hong Kong-China,561.0,545.0,555.0,HK,553.6666666666666
S.Korea,554.0,536.0,538.0,KR,542.6666666666666
Japan,536.0,538.0,547.0,JP,540.3333333333334
Taiwan,560.0,523.0,523.0,TW,535.3333333333334
Finland,519.0,524.0,545.0,FI,529.3333333333334
Estonia,521.0,516.0,541.0,EE,526.0
Liechtenstein,535.0,516.0,525.0,LI,525.3333333333334
Macau-China,538.0,509.0,521.0,MO,522.6666666666666
Canada,518.0,523.0,525.0,CA,522.0
Poland,518.0,518.0,526.0,PL,520.6666666666666
Netherlands,523.0,511.0,522.0,NL,518.6666666666666
Switzerland,531.0,509.0,515.0,CH,518.3333333333334
Vietnam,511.0,508.0,528.0,VN,515.6666666666666
Germany,514.0,508.0,524.0,DE,515.3333333333334
Ireland,501.0,523.0,522.0,IE,515.3333333333334
Australia,504.0,512.0,521.0,AU,512.3333333333334
Belgium,515.0,509.0,505.0,BE,509.6666666666667
New Zealand,500.0,512.0,516.0,NZ,509.3333333333333
UK,494.0,499.0,514.0,UK,502.3333333333333
Austria,506.0,490.0,506.0,AT,500.6666666666667
Czech Republic,499.0,493.0,508.0,CZ,500.0
France,495.0,505.0,499.0,FR,499.6666666666667
Slovenia,501.0,481.0,514.0,SI,498.6666666666667
Denmark,500.0,496.0,498.0,DK,498.0
Norway,489.0,504.0,495.0,NO,496.0
Latvia,491.0,489.0,502.0,LV,494.0
USA,481.0,498.0,497.0,US,492.0
Italy,485.0,490.0,494.0,IT,489.6666666666667
Luxembourg,490.0,488.0,491.0,LU,489.6666666666667
Spain,484.0,488.0,496.0,ES,489.3333333333333
Portugal,487.0,488.0,489.0,PT,488.0
Hungary,477.0,488.0,494.0,HU,486.3333333333333
Iceland,493.0,483.0,478.0,IS,484.6666666666667
Lithuania,479.0,477.0,496.0,LT,484.0
Croatia,471.0,485.0,491.0,HR,482.3333333333333
Sweden,478.0,483.0,485.0,SE,482.0
Russian Federation,482.0,475.0,486.0,RU,481.0
Israel,466.0,486.0,470.0,IL,474.0
Slovak Republic,482.0,463.0,471.0,SK,472.0
Greece,453.0,477.0,467.0,GR,465.6666666666667
Turkey,448.0,475.0,463.0,TR,462.0
Serbia,449.0,446.0,445.0,RS,446.6666666666667
Cyprus,440.0,449.0,438.0,CY,442.3333333333333
UAE,434.0,442.0,448.0,AE,441.3333333333333
Romania,445.0,438.0,439.0,RO,440.6666666666667
Bulgaria,439.0,436.0,446.0,BG,440.3333333333333
Thailand,427.0,441.0,444.0,TH,437.3333333333333
Chile,423.0,441.0,445.0,CL,436.3333333333333
Costa Rica,407.0,441.0,429.0,CR,425.6666666666667
Mexico,413.0,424.0,415.0,MX,417.3333333333333
Kazakhstan,432.0,393.0,425.0,KZ,416.6666666666667
Montenegro,410.0,422.0,410.0,ME,414.0
Malaysia,421.0,398.0,420.0,MY,413.0
Uruguay,409.0,411.0,416.0,UY,412.0
Brazil,391.0,410.0,405.0,BR,402.0
Jordan,386.0,399.0,409.0,JO,398.0
Tunisia,388.0,404.0,398.0,TN,396.6666666666667
Argentina,388.0,396.0,406.0,AR,396.6666666666667
Albania,394.0,394.0,397.0,AL,395.0
Colombia,376.0,403.0,399.0,CO,392.6666666666667
Indonesia,375.0,396.0,382.0,ID,384.3333333333333
Qatar,376.0,388.0,384.0,QA,382.6666666666667
Peru,368.0,384.0,373.0,PE,375.0
1 Shanghai-China 613.0 570.0 580.0 CN 587.6666666666666
2 Singapore 573.0 542.0 551.0 SG 555.3333333333334
3 Hong Kong-China 561.0 545.0 555.0 HK 553.6666666666666
4 S.Korea 554.0 536.0 538.0 KR 542.6666666666666
5 Japan 536.0 538.0 547.0 JP 540.3333333333334
6 Taiwan 560.0 523.0 523.0 TW 535.3333333333334
7 Finland 519.0 524.0 545.0 FI 529.3333333333334
8 Estonia 521.0 516.0 541.0 EE 526.0
9 Liechtenstein 535.0 516.0 525.0 LI 525.3333333333334
10 Macau-China 538.0 509.0 521.0 MO 522.6666666666666
11 Canada 518.0 523.0 525.0 CA 522.0
12 Poland 518.0 518.0 526.0 PL 520.6666666666666
13 Netherlands 523.0 511.0 522.0 NL 518.6666666666666
14 Switzerland 531.0 509.0 515.0 CH 518.3333333333334
15 Vietnam 511.0 508.0 528.0 VN 515.6666666666666
16 Germany 514.0 508.0 524.0 DE 515.3333333333334
17 Ireland 501.0 523.0 522.0 IE 515.3333333333334
18 Australia 504.0 512.0 521.0 AU 512.3333333333334
19 Belgium 515.0 509.0 505.0 BE 509.6666666666667
20 New Zealand 500.0 512.0 516.0 NZ 509.3333333333333
21 UK 494.0 499.0 514.0 UK 502.3333333333333
22 Austria 506.0 490.0 506.0 AT 500.6666666666667
23 Czech Republic 499.0 493.0 508.0 CZ 500.0
24 France 495.0 505.0 499.0 FR 499.6666666666667
25 Slovenia 501.0 481.0 514.0 SI 498.6666666666667
26 Denmark 500.0 496.0 498.0 DK 498.0
27 Norway 489.0 504.0 495.0 NO 496.0
28 Latvia 491.0 489.0 502.0 LV 494.0
29 USA 481.0 498.0 497.0 US 492.0
30 Italy 485.0 490.0 494.0 IT 489.6666666666667
31 Luxembourg 490.0 488.0 491.0 LU 489.6666666666667
32 Spain 484.0 488.0 496.0 ES 489.3333333333333
33 Portugal 487.0 488.0 489.0 PT 488.0
34 Hungary 477.0 488.0 494.0 HU 486.3333333333333
35 Iceland 493.0 483.0 478.0 IS 484.6666666666667
36 Lithuania 479.0 477.0 496.0 LT 484.0
37 Croatia 471.0 485.0 491.0 HR 482.3333333333333
38 Sweden 478.0 483.0 485.0 SE 482.0
39 Russian Federation 482.0 475.0 486.0 RU 481.0
40 Israel 466.0 486.0 470.0 IL 474.0
41 Slovak Republic 482.0 463.0 471.0 SK 472.0
42 Greece 453.0 477.0 467.0 GR 465.6666666666667
43 Turkey 448.0 475.0 463.0 TR 462.0
44 Serbia 449.0 446.0 445.0 RS 446.6666666666667
45 Cyprus 440.0 449.0 438.0 CY 442.3333333333333
46 UAE 434.0 442.0 448.0 AE 441.3333333333333
47 Romania 445.0 438.0 439.0 RO 440.6666666666667
48 Bulgaria 439.0 436.0 446.0 BG 440.3333333333333
49 Thailand 427.0 441.0 444.0 TH 437.3333333333333
50 Chile 423.0 441.0 445.0 CL 436.3333333333333
51 Costa Rica 407.0 441.0 429.0 CR 425.6666666666667
52 Mexico 413.0 424.0 415.0 MX 417.3333333333333
53 Kazakhstan 432.0 393.0 425.0 KZ 416.6666666666667
54 Montenegro 410.0 422.0 410.0 ME 414.0
55 Malaysia 421.0 398.0 420.0 MY 413.0
56 Uruguay 409.0 411.0 416.0 UY 412.0
57 Brazil 391.0 410.0 405.0 BR 402.0
58 Jordan 386.0 399.0 409.0 JO 398.0
59 Tunisia 388.0 404.0 398.0 TN 396.6666666666667
60 Argentina 388.0 396.0 406.0 AR 396.6666666666667
61 Albania 394.0 394.0 397.0 AL 395.0
62 Colombia 376.0 403.0 399.0 CO 392.6666666666667
63 Indonesia 375.0 396.0 382.0 ID 384.3333333333333
64 Qatar 376.0 388.0 384.0 QA 382.6666666666667
65 Peru 368.0 384.0 373.0 PE 375.0

BIN
practice1/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

74
practice1/test.py Normal file
View File

@ -0,0 +1,74 @@
import pandas as pd
from matplotlib import pyplot as plt, colors
from matplotlib.font_manager import FontProperties
import numpy as np
subjects = ["Maths", "Reading", "Science"]
data = pd.read_csv("./practice1.csv", names=["country", *subjects])
country_codes = pd.read_csv("./country_codes.csv", names=["country", "code"])
data = data.merge(country_codes, how="outer", on="country")
data = data.dropna(subset=subjects)
data["Average"] = data.loc[:, subjects].mean(axis=1)
data = data.sort_values(by="Average", ascending=False)
data.to_csv("res.csv", index=False, header=False)
if data[data["code"].isna()].size != 0:
raise ValueError("NaN country code")
fig, ax = plt.subplots(nrows=4)
fig.set_size_inches(16, 11.69)
positions = np.array(list(map(str,range(1, len(data.index)+1))))
x = data["code"] + "\n" + positions
# colors=("#ef476f", "#ffd166", "#06d6a0", "#118ab2", "#073B4C")
colors=("tab:blue", "tab:orange", "tab:green", "tab:red", "tab:grey")
subjects_labels = ("🔢", "📚", "🔬", "")
for i, subj in enumerate((*subjects, "Average")):
bar = ax[i].bar(x, data[subj], color=colors[i])
bar_labels = list(map(lambda j: str(int(data[subj][data.index[j]])) if data["code"][data.index[j]] == "UK" else "", range(len(data.index))))
ax[i].bar_label(bar, labels=bar_labels, weight="bold")
ax[i].set_title(subjects_labels[i])
ax[i].autoscale(tight=True)
ax[i].set_ylim(350)
mean = int(data[subj].mean())
ax[i].set_yticks(list(set((*ax[i].get_yticks(), mean, 650))))
for label in ax[i].get_xticklabels():
if "UK" in label.get_text():
label.set(fontweight="bold")
for label in ax[i].get_yticklabels():
if label.get_text() == str(mean):
label.set(fontweight="bold")
ax[i].hlines([mean], 0, 1, transform=ax[i].get_yaxis_transform(), color=colors[-1])
ax[i].spines['top'].set_visible(False)
ax[i].spines['right'].set_visible(False)
ax[i].spines['bottom'].set_visible(False)
ax[i].spines['left'].set_visible(False)
# ax[i].grid()
fig.tight_layout()
fig.savefig("test.png")