finished
This commit is contained in:
commit
3af1df451c
2
practice1/.gitignore
vendored
Normal file
2
practice1/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.venv
|
||||
.~lock*
|
249
practice1/country_codes.csv
Normal file
249
practice1/country_codes.csv
Normal 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
|
|
BIN
practice1/initial.png
Normal file
BIN
practice1/initial.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 323 KiB |
287
practice1/main.ipynb
Normal file
287
practice1/main.ipynb
Normal file
File diff suppressed because one or more lines are too long
BIN
practice1/output.png
Normal file
BIN
practice1/output.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 150 KiB |
BIN
practice1/output2.png
Normal file
BIN
practice1/output2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 123 KiB |
BIN
practice1/output3.png
Normal file
BIN
practice1/output3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 69 KiB |
65
practice1/practice1.csv
Normal file
65
practice1/practice1.csv
Normal 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
|
|
BIN
practice1/practice1.ods
Normal file
BIN
practice1/practice1.ods
Normal file
Binary file not shown.
BIN
practice1/report.odt
Normal file
BIN
practice1/report.odt
Normal file
Binary file not shown.
BIN
practice1/report.pdf
Normal file
BIN
practice1/report.pdf
Normal file
Binary file not shown.
65
practice1/res.csv
Normal file
65
practice1/res.csv
Normal 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
|
|
BIN
practice1/test.png
Normal file
BIN
practice1/test.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 117 KiB |
74
practice1/test.py
Normal file
74
practice1/test.py
Normal 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")
|
Loading…
x
Reference in New Issue
Block a user