Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
3e379fb269 | |||
0959678e9f | |||
c6100fbc87 | |||
7e49164224 | |||
8e46b858c3 | |||
80f9066aed | |||
f93f5830e4 | |||
0fa75f61e7 | |||
c5543322de | |||
66213a9bc5 | |||
27938a9f0f | |||
efe847fcae | |||
4d8e263857 |
Binary file not shown.
File diff suppressed because it is too large
Load Diff
111070
labs06/311.csv
111070
labs06/311.csv
File diff suppressed because it is too large
Load Diff
@ -1,18 +0,0 @@
|
|||||||
## Zadania
|
|
||||||
|
|
||||||
** zad. 0 **
|
|
||||||
Sprawdź, czy masz zainstalowany pakiet ``pandas``. Jeżeli nie, zainstaluj go.
|
|
||||||
|
|
||||||
** zad. 2 (domowe) **
|
|
||||||
Jest to zadanie złożone, składające się z kilku części. Całość będzie opierać się o dane zawarte w pliku *mieszkania.csv* i dotyczą cen mieszkań w Poznaniu kilka lat temu.
|
|
||||||
1, Otwórz plik ``task02.py``, który zawiera szkielet kodu, który będziemy rozwijać w tym zadaniu.
|
|
||||||
1. Napisz funkcje, która wczyta zestaw danych z pliku *mieszkania.csv* i zwróci obiekt typu *DataFrame*. Jeżeli wszystko zostało zrobione poprawnie, powinno się wyśtwietlić 5 pierwszych wierszy.
|
|
||||||
1. Uzupełnij funkcję ``most_common_room_number``, która zwróci jaka jest najpopularniejsza liczba pokoi w ogłoszeniach. Funkcji powinna zwrócić liczbę całkowitą.
|
|
||||||
1. Uzupełnij kod w funkcji ``cheapest_flats(dane, n)``, która wzróci *n* najtańszych ofert mieszkań. Wzrócony obiekt typu ``DataFrame``.
|
|
||||||
1. Napisz funkcje ``find_borough(desc)``, która przyjmuje 1 argument typu *string* i zwróci jedną z dzielnic zdefiniowaną w liście ``dzielnice``. Funkcja ma zwrócić pierwszą (wzgledem kolejności) nazwę dzielnicy, która jest zawarta w ``desc``. Jeżeli żadna nazwa nie została odnaleziona, zwróć *Inne*.
|
|
||||||
1. Dodaj kolumnę ``Borough``, która będzie zawierać informacje o dzielnicach i powstanie z kolumny ``Localization``. Wykorzystaj do tego funkcję ``find_borough``.
|
|
||||||
1. Uzupełnił funkcje ``write_plot``, która zapisze do pliku ``filename`` wykres słupkowy przedstawiający liczbę ogłoszeń mieszkań z podziałem na dzielnice.
|
|
||||||
1. Napisz funkcje ``mean_price``, która zwróci średnią cenę mieszkania ``room_numer``-pokojowego.
|
|
||||||
1. Uzupełnij funkcje ``find_13``, która zwróci listę dzielnic, które zawierają ofertę mieszkanie na 13 piętrze.
|
|
||||||
1. Napisz funkcje ``find_best_flats``, która zwróci wszystkie ogłoszenia mieszkań, które znajdują się na Winogradach, mają 3 pokoje i są położone na 1 piętrze.
|
|
||||||
1. *(dodatkowe)*: Korzystając z pakietu *sklearn* zbuduj model regresji liniowej, która będzie wyznaczać cenę mieszkania na podstawie wielkości mieszkania i liczby pokoi.
|
|
File diff suppressed because it is too large
Load Diff
@ -1,54 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
def wczytaj_dane():
|
|
||||||
pass
|
|
||||||
|
|
||||||
def most_common_room_number(dane):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def cheapest_flats(dane, n):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def find_borough(desc):
|
|
||||||
dzielnice = ['Stare Miasto',
|
|
||||||
'Wilda',
|
|
||||||
'Jeżyce',
|
|
||||||
'Rataje',
|
|
||||||
'Piątkowo',
|
|
||||||
'Winogrady',
|
|
||||||
'Miłostowo',
|
|
||||||
'Dębiec']
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def add_borough(dane):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def write_plot(dane, filename):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def mean_price(dane, room_number):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def find_13(dane):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def find_best_flats(dane):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def main():
|
|
||||||
dane = wczytaj_dane()
|
|
||||||
print(dane[:5])
|
|
||||||
|
|
||||||
print("Najpopularniejsza liczba pokoi w mieszkaniu to: {}"
|
|
||||||
.format(most_common_room_number(dane)))
|
|
||||||
|
|
||||||
print("{} to najłądniejsza dzielnica w Poznaniu."
|
|
||||||
.format(find_borough("Grunwald i Jeżyce"))))
|
|
||||||
|
|
||||||
print("Średnia cena mieszkania 3-pokojowego, to: {}"
|
|
||||||
.format(mean_price(dane, 3)))
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
@ -1,80 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
"""
|
|
||||||
1. Zaimportuj bibliotkę pandas jako pd.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
2. Wczytaj zbiór danych `311.csv` do zniennej data.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
3. Wyświetl 5 pierwszych wierszy z data.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
4. Wyświetl nazwy kolumn.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
5. Wyświetl ile nasz zbiór danych ma kolumn i wierszy.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
6. Wyświetl kolumnę 'City' z powyższego zbioru danych.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
7. Wyświetl jakie wartoścu przyjmuje kolumna 'City'.
|
|
||||||
"""
|
|
||||||
|
|
||||||
"""
|
|
||||||
8. Wyświetl tabelę rozstawną kolumny City.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
9. Wyświetl tylko pierwsze 4 wiersze z wcześniejszego polecenia.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
10. Wyświetl, w ilu przypadkach kolumna City zawiera NaN.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
11. Wyświetl data.info()
|
|
||||||
"""
|
|
||||||
|
|
||||||
"""
|
|
||||||
12. Wyświetl tylko kolumny Borough i Agency i tylko 5 ostatnich linii.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
13. Wyświetl tylko te dane, dla których wartość z kolumny Agency jest równa
|
|
||||||
NYPD. Zlicz ile jest takich przykładów.
|
|
||||||
"""
|
|
||||||
|
|
||||||
"""
|
|
||||||
14. Wyświetl wartość minimalną i maksymalną z kolumny Longitude.
|
|
||||||
"""
|
|
||||||
|
|
||||||
"""
|
|
||||||
15. Dodaj kolumne diff, która powstanie przez sumowanie kolumn Longitude i Latitude.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
16. Wyświetl tablę rozstawną dla kolumny 'Descriptor', dla której Agency jest
|
|
||||||
równe NYPD.
|
|
||||||
"""
|
|
@ -1,177 +0,0 @@
|
|||||||
,female_BMI,male_BMI,gdp,population,under5mortality,life_expectancy,fertility
|
|
||||||
Afghanistan,21.07402,20.62058,1311.0,26528741.0,110.4,52.8,6.2
|
|
||||||
Albania,25.65726,26.44657,8644.0,2968026.0,17.9,76.8,1.76
|
|
||||||
Algeria,26.368409999999997,24.5962,12314.0,34811059.0,29.5,75.5,2.73
|
|
||||||
Angola,23.48431,22.25083,7103.0,19842251.0,192.0,56.7,6.43
|
|
||||||
Antigua and Barbuda,27.50545,25.76602,25736.0,85350.0,10.9,75.5,2.16
|
|
||||||
Argentina,27.46523,27.5017,14646.0,40381860.0,15.4,75.4,2.24
|
|
||||||
Armenia,27.1342,25.355420000000002,7383.0,2975029.0,20.0,72.3,1.4
|
|
||||||
Australia,26.87777,27.56373,41312.0,21370348.0,5.2,81.6,1.96
|
|
||||||
Austria,25.09414,26.467409999999997,43952.0,8331465.0,4.6,80.4,1.41
|
|
||||||
Azerbaijan,27.50879,25.65117,14365.0,8868713.0,43.3,69.2,1.99
|
|
||||||
Bahamas,29.13948,27.24594,24373.0,348587.0,14.5,72.2,1.89
|
|
||||||
Bahrain,28.790940000000003,27.83721,42507.0,1115777.0,9.4,77.6,2.23
|
|
||||||
Bangladesh,20.54531,20.39742,2265.0,148252473.0,55.9,68.3,2.38
|
|
||||||
Barbados,29.221690000000002,26.384390000000003,16075.0,277315.0,15.4,75.3,1.83
|
|
||||||
Belarus,26.641859999999998,26.16443,14488.0,9526453.0,7.2,70.0,1.42
|
|
||||||
Belgium,25.1446,26.75915,41641.0,10779155.0,4.7,79.6,1.82
|
|
||||||
Belize,29.81663,27.02255,8293.0,306165.0,20.1,70.7,2.91
|
|
||||||
Benin,23.74026,22.41835,1646.0,8973525.0,116.3,59.7,5.27
|
|
||||||
Bhutan,22.88243,22.8218,5663.0,694990.0,48.1,70.7,2.51
|
|
||||||
Bolivia,26.8633,24.43335,5066.0,9599916.0,52.0,71.2,3.48
|
|
||||||
Bosnia and Herzegovina,26.35874,26.611629999999998,9316.0,3839749.0,8.1,77.5,1.22
|
|
||||||
Botswana,26.09156,22.129839999999998,13858.0,1967866.0,63.8,53.2,2.86
|
|
||||||
Brazil,25.99113,25.78623,13906.0,194769696.0,18.6,73.2,1.9
|
|
||||||
Brunei,22.892310000000002,24.18179,72351.0,380786.0,9.0,76.9,2.1
|
|
||||||
Bulgaria,25.51574,26.542859999999997,15368.0,7513646.0,13.7,73.2,1.43
|
|
||||||
Burkina Faso,21.63031,21.27157,1358.0,14709011.0,130.4,58.0,6.04
|
|
||||||
Burundi,21.27927,21.50291,723.0,8821795.0,108.6,59.1,6.48
|
|
||||||
Cambodia,21.69608,20.80496,2442.0,13933660.0,51.5,66.1,3.05
|
|
||||||
Cameroon,24.9527,23.681729999999998,2571.0,19570418.0,113.8,56.6,5.17
|
|
||||||
Canada,26.698290000000004,27.4521,41468.0,33363256.0,5.8,80.8,1.68
|
|
||||||
Cape Verde,24.96136,23.515220000000003,6031.0,483824.0,28.4,70.4,2.57
|
|
||||||
Chad,21.95424,21.485689999999998,1753.0,11139740.0,168.0,54.3,6.81
|
|
||||||
Chile,27.92807,27.015420000000002,18698.0,16645940.0,8.9,78.5,1.89
|
|
||||||
China,22.91041,22.92176,7880.0,1326690636.0,18.5,73.4,1.53
|
|
||||||
Colombia,26.22529,24.94041,10489.0,44901660.0,19.7,76.2,2.43
|
|
||||||
Comoros,22.444329999999997,22.06131,1440.0,665414.0,91.2,67.1,5.05
|
|
||||||
"Congo, Dem. Rep.",21.6677,19.86692,607.0,61809278.0,124.5,57.5,6.45
|
|
||||||
"Congo, Rep.",23.10824,21.87134,5022.0,3832771.0,72.6,58.8,5.1
|
|
||||||
Costa Rica,27.03497,26.47897,12219.0,4429506.0,10.3,79.8,1.91
|
|
||||||
Cote d'Ivoire,23.82088,22.56469,2854.0,19261647.0,116.9,55.4,4.91
|
|
||||||
Croatia,25.17882,26.596290000000003,21873.0,4344151.0,5.9,76.2,1.43
|
|
||||||
Cuba,26.576140000000002,25.06867,17765.0,11290239.0,6.3,77.6,1.5
|
|
||||||
Cyprus,25.92587,27.41899,35828.0,1077010.0,4.2,80.0,1.49
|
|
||||||
Denmark,25.106270000000002,26.13287,45017.0,5495302.0,4.3,78.9,1.89
|
|
||||||
Djibouti,24.38177,23.38403,2502.0,809639.0,81.0,61.8,3.76
|
|
||||||
Ecuador,27.062690000000003,25.58841,9244.0,14447600.0,26.8,74.7,2.73
|
|
||||||
Egypt,30.099970000000003,26.732429999999997,9974.0,78976122.0,31.4,70.2,2.95
|
|
||||||
El Salvador,27.84092,26.36751,7450.0,6004199.0,21.6,73.7,2.32
|
|
||||||
Equatorial Guinea,24.528370000000002,23.7664,40143.0,686223.0,118.4,57.5,5.31
|
|
||||||
Eritrea,21.082320000000003,20.885089999999998,1088.0,4500638.0,60.4,60.1,5.16
|
|
||||||
Estonia,25.185979999999997,26.264459999999996,24743.0,1339941.0,5.5,74.2,1.62
|
|
||||||
Ethiopia,20.71463,20.247,931.0,83079608.0,86.9,60.0,5.19
|
|
||||||
Fiji,29.339409999999997,26.53078,7129.0,843206.0,24.0,64.9,2.74
|
|
||||||
Finland,25.58418,26.733390000000004,42122.0,5314170.0,3.3,79.6,1.85
|
|
||||||
France,24.82949,25.853289999999998,37505.0,62309529.0,4.3,81.1,1.97
|
|
||||||
Gabon,25.95121,24.0762,15800.0,1473741.0,68.0,61.7,4.28
|
|
||||||
Gambia,24.82101,21.65029,1566.0,1586749.0,87.4,65.7,5.8
|
|
||||||
Georgia,26.45014,25.54942,5900.0,4343290.0,19.3,71.8,1.79
|
|
||||||
Germany,25.73903,27.165090000000003,41199.0,80665906.0,4.4,80.0,1.37
|
|
||||||
Ghana,24.33014,22.842470000000002,2907.0,23115919.0,79.9,62.0,4.19
|
|
||||||
Greece,24.92026,26.33786,32197.0,11161755.0,4.9,80.2,1.46
|
|
||||||
Grenada,27.31948,25.179879999999997,12116.0,103934.0,13.5,70.8,2.28
|
|
||||||
Guatemala,26.84324,25.29947,6960.0,14106687.0,36.9,71.2,4.12
|
|
||||||
Guinea,22.45206,22.52449,1230.0,10427356.0,121.0,57.1,5.34
|
|
||||||
Guinea-Bissau,22.92809,21.64338,1326.0,1561293.0,127.6,53.6,5.25
|
|
||||||
Guyana,26.470190000000002,23.68465,5208.0,748096.0,41.9,65.0,2.74
|
|
||||||
Haiti,23.27785,23.66302,1600.0,9705130.0,83.3,61.0,3.5
|
|
||||||
Honduras,26.73191,25.10872,4391.0,7259470.0,26.5,71.8,3.27
|
|
||||||
"Hong Kong, China",23.71046,25.057470000000002,46635.0,6910384.0,3.06,82.49,1.04
|
|
||||||
Hungary,25.97839,27.115679999999998,23334.0,10050699.0,7.2,73.9,1.33
|
|
||||||
Iceland,26.02599,27.206870000000002,42294.0,310033.0,2.7,82.4,2.12
|
|
||||||
India,21.31478,20.95956,3901.0,1197070109.0,65.6,64.7,2.64
|
|
||||||
Indonesia,22.986929999999997,21.85576,7856.0,235360765.0,36.2,69.4,2.48
|
|
||||||
Iran,27.236079999999998,25.310029999999998,15955.0,72530693.0,21.4,73.1,1.88
|
|
||||||
Iraq,28.411170000000002,26.71017,11616.0,29163327.0,38.3,66.6,4.34
|
|
||||||
Ireland,26.62176,27.65325,47713.0,4480145.0,4.5,80.1,2.0
|
|
||||||
Israel,27.301920000000003,27.13151,28562.0,7093808.0,4.9,80.6,2.92
|
|
||||||
Italy,24.79289,26.4802,37475.0,59319234.0,4.1,81.5,1.39
|
|
||||||
Jamaica,27.22601,24.00421,8951.0,2717344.0,18.9,75.1,2.39
|
|
||||||
Japan,21.87088,23.50004,34800.0,127317900.0,3.4,82.5,1.34
|
|
||||||
Jordan,29.218009999999996,27.47362,10897.0,6010035.0,22.1,76.9,3.59
|
|
||||||
Kazakhstan,26.65065,26.290779999999998,18797.0,15915966.0,25.9,67.1,2.51
|
|
||||||
Kenya,23.06181,21.592579999999998,2358.0,38244442.0,71.0,60.8,4.76
|
|
||||||
Kiribati,31.30769,29.2384,1803.0,98437.0,64.5,61.5,3.13
|
|
||||||
Kuwait,31.161859999999997,29.172109999999996,91966.0,2705290.0,11.3,77.3,2.68
|
|
||||||
Latvia,25.615129999999997,26.45693,20977.0,2144215.0,10.5,72.4,1.5
|
|
||||||
Lebanon,27.70471,27.20117,14158.0,4109389.0,11.3,77.8,1.57
|
|
||||||
Lesotho,26.780520000000003,21.90157,2041.0,1972194.0,114.2,44.5,3.34
|
|
||||||
Liberia,23.21679,21.89537,588.0,3672782.0,100.9,59.9,5.19
|
|
||||||
Libya,29.19874,26.54164,29853.0,6123022.0,18.8,75.6,2.64
|
|
||||||
Lithuania,26.01424,26.86102,23223.0,3219802.0,8.2,72.1,1.42
|
|
||||||
Luxembourg,26.09326,27.434040000000003,95001.0,485079.0,2.8,81.0,1.63
|
|
||||||
"Macao, China",24.895039999999998,25.713820000000002,80191.0,507274.0,6.72,79.32,0.94
|
|
||||||
"Macedonia, FYR",25.37646,26.34473,10872.0,2055266.0,11.8,74.5,1.47
|
|
||||||
Madagascar,20.73501,21.403470000000002,1528.0,19926798.0,66.7,62.2,4.79
|
|
||||||
Malawi,22.91455,22.034679999999998,674.0,13904671.0,101.1,52.4,5.78
|
|
||||||
Malaysia,25.448320000000002,24.73069,19968.0,27197419.0,8.0,74.5,2.05
|
|
||||||
Maldives,26.4132,23.219910000000002,12029.0,321026.0,16.0,78.5,2.38
|
|
||||||
Mali,23.07655,21.78881,1602.0,14223403.0,148.3,58.5,6.82
|
|
||||||
Malta,27.04993,27.683609999999998,27872.0,406392.0,6.6,80.7,1.38
|
|
||||||
Mauritania,26.26476,22.62295,3356.0,3414552.0,103.0,67.9,4.94
|
|
||||||
Mauritius,26.09824,25.15669,14615.0,1238013.0,15.8,72.9,1.58
|
|
||||||
Mexico,28.737509999999997,27.42468,15826.0,114972821.0,17.9,75.4,2.35
|
|
||||||
"Micronesia, Fed. Sts.",31.28402,28.10315,3197.0,104472.0,43.1,68.0,3.59
|
|
||||||
Moldova,27.05617,24.2369,3890.0,4111168.0,17.6,70.4,1.49
|
|
||||||
Mongolia,25.71375,24.88385,7563.0,2629666.0,34.8,64.8,2.37
|
|
||||||
Montenegro,25.70186,26.55412,14183.0,619740.0,8.1,76.0,1.72
|
|
||||||
Morocco,26.223090000000003,25.63182,6091.0,31350544.0,35.8,73.3,2.44
|
|
||||||
Mozambique,23.317339999999998,21.93536,864.0,22994867.0,114.4,54.0,5.54
|
|
||||||
Myanmar,22.47733,21.44932,2891.0,51030006.0,87.2,59.4,2.05
|
|
||||||
Namibia,25.14988,22.65008,8169.0,2115703.0,62.2,59.1,3.36
|
|
||||||
Nepal,20.72814,20.76344,1866.0,26325183.0,50.7,68.4,2.9
|
|
||||||
Netherlands,25.47269,26.01541,47388.0,16519862.0,4.8,80.3,1.77
|
|
||||||
New Zealand,27.36642,27.768929999999997,32122.0,4285380.0,6.4,80.3,2.12
|
|
||||||
Nicaragua,27.57259,25.77291,4060.0,5594524.0,28.1,77.0,2.72
|
|
||||||
Niger,21.95958,21.21958,843.0,15085130.0,141.3,58.0,7.59
|
|
||||||
Nigeria,23.674020000000002,23.03322,4684.0,151115683.0,140.9,59.2,6.02
|
|
||||||
Norway,25.73772,26.934240000000003,65216.0,4771633.0,3.6,80.8,1.96
|
|
||||||
Oman,26.66535,26.241090000000003,47799.0,2652281.0,11.9,76.2,2.89
|
|
||||||
Pakistan,23.44986,22.299139999999998,4187.0,163096985.0,95.5,64.1,3.58
|
|
||||||
Panama,27.67758,26.26959,14033.0,3498679.0,21.0,77.3,2.61
|
|
||||||
Papua New Guinea,25.77189,25.015060000000002,1982.0,6540267.0,69.7,58.6,4.07
|
|
||||||
Paraguay,25.90523,25.54223,6684.0,6047131.0,25.7,74.0,3.06
|
|
||||||
Peru,25.98511,24.770410000000002,9249.0,28642048.0,23.2,78.2,2.58
|
|
||||||
Philippines,23.4671,22.872629999999997,5332.0,90297115.0,33.4,69.8,3.26
|
|
||||||
Poland,25.918870000000002,26.6738,19996.0,38525752.0,6.7,75.4,1.33
|
|
||||||
Portugal,26.183020000000003,26.68445,27747.0,10577458.0,4.1,79.4,1.36
|
|
||||||
Puerto Rico,30.2212,28.378040000000002,35855.0,3728126.0,8.78,77.0,1.69
|
|
||||||
Qatar,28.912509999999997,28.13138,126076.0,1388962.0,9.5,77.9,2.2
|
|
||||||
Romania,25.22425,25.41069,18032.0,20741669.0,16.1,73.2,1.34
|
|
||||||
Russia,27.21272,26.01131,22506.0,143123163.0,13.5,67.9,1.49
|
|
||||||
Rwanda,22.07156,22.55453,1173.0,9750314.0,78.3,64.1,5.06
|
|
||||||
Samoa,33.659079999999996,30.42475,5731.0,183440.0,18.8,72.3,4.43
|
|
||||||
Sao Tome and Principe,24.88216,23.51233,2673.0,163595.0,61.0,66.0,4.41
|
|
||||||
Saudi Arabia,29.598779999999998,27.884320000000002,44189.0,26742842.0,18.1,78.3,2.97
|
|
||||||
Senegal,24.30968,21.927429999999998,2162.0,12229703.0,75.8,63.5,5.11
|
|
||||||
Serbia,25.669970000000003,26.51495,12522.0,9109535.0,8.0,74.3,1.41
|
|
||||||
Seychelles,27.973740000000003,25.56236,20065.0,91634.0,14.2,72.9,2.28
|
|
||||||
Sierra Leone,23.93364,22.53139,1289.0,5521838.0,179.1,53.6,5.13
|
|
||||||
Singapore,22.86642,23.83996,65991.0,4849641.0,2.8,80.6,1.28
|
|
||||||
Slovak Republic,26.323729999999998,26.92717,24670.0,5396710.0,8.8,74.9,1.31
|
|
||||||
Slovenia,26.582140000000003,27.43983,30816.0,2030599.0,3.7,78.7,1.43
|
|
||||||
Solomon Islands,28.8762,27.159879999999998,1835.0,503410.0,33.1,62.3,4.36
|
|
||||||
Somalia,22.66607,21.969170000000002,615.0,9132589.0,168.5,52.6,7.06
|
|
||||||
South Africa,29.4803,26.85538,12263.0,50348811.0,66.1,53.4,2.54
|
|
||||||
Spain,26.30554,27.49975,34676.0,45817016.0,5.0,81.1,1.42
|
|
||||||
Sri Lanka,23.11717,21.96671,6907.0,19949553.0,11.7,74.0,2.32
|
|
||||||
Sudan,23.16132,22.40484,3246.0,34470138.0,84.7,65.5,4.79
|
|
||||||
Suriname,27.749859999999998,25.49887,13470.0,506657.0,26.4,70.2,2.41
|
|
||||||
Swaziland,28.448859999999996,23.16969,5887.0,1153750.0,112.2,45.1,3.7
|
|
||||||
Sweden,25.1466,26.37629,43421.0,9226333.0,3.2,81.1,1.92
|
|
||||||
Switzerland,24.07242,26.20195,55020.0,7646542.0,4.7,82.0,1.47
|
|
||||||
Syria,28.87418,26.919690000000003,6246.0,20097057.0,16.5,76.1,3.17
|
|
||||||
Tajikistan,23.84799,23.77966,2001.0,7254072.0,56.2,69.6,3.7
|
|
||||||
Tanzania,23.0843,22.47792,2030.0,42844744.0,72.4,60.4,5.54
|
|
||||||
Thailand,24.38577,23.008029999999998,12216.0,66453255.0,15.6,73.9,1.48
|
|
||||||
Timor-Leste,21.50694,20.59082,1486.0,1030915.0,70.2,69.9,6.48
|
|
||||||
Togo,22.73858,21.87875,1219.0,6052937.0,96.4,57.5,4.88
|
|
||||||
Tonga,34.25969,30.99563,4748.0,102816.0,17.0,70.3,4.01
|
|
||||||
Trinidad and Tobago,28.27587,26.396690000000003,30875.0,1315372.0,24.9,71.7,1.8
|
|
||||||
Tunisia,27.93706,25.15699,9938.0,10408091.0,19.4,76.8,2.04
|
|
||||||
Turkey,28.247490000000003,26.703709999999997,16454.0,70344357.0,22.2,77.8,2.15
|
|
||||||
Turkmenistan,24.66154,25.24796,8877.0,4917541.0,63.9,67.2,2.48
|
|
||||||
Uganda,22.48126,22.35833,1437.0,31014427.0,89.3,56.0,6.34
|
|
||||||
Ukraine,26.23317,25.42379,8762.0,46028476.0,12.9,67.8,1.38
|
|
||||||
United Arab Emirates,29.614009999999997,28.053590000000003,73029.0,6900142.0,9.1,75.6,1.95
|
|
||||||
United Kingdom,26.944490000000002,27.392490000000002,37739.0,61689620.0,5.6,79.7,1.87
|
|
||||||
United States,28.343590000000003,28.456979999999998,50384.0,304473143.0,7.7,78.3,2.07
|
|
||||||
Uruguay,26.593040000000002,26.39123,15317.0,3350832.0,13.0,76.0,2.11
|
|
||||||
Uzbekistan,25.43432,25.32054,3733.0,26952719.0,49.2,69.6,2.46
|
|
||||||
Vanuatu,28.458759999999998,26.78926,2944.0,225335.0,28.2,63.4,3.61
|
|
||||||
Venezuela,28.134079999999997,27.445,17911.0,28116716.0,17.1,74.2,2.53
|
|
||||||
Vietnam,21.065,20.9163,4085.0,86589342.0,26.2,74.1,1.86
|
|
||||||
West Bank and Gaza,29.026429999999998,26.5775,3564.0,3854667.0,24.7,74.1,4.38
|
|
||||||
Zambia,23.05436,20.68321,3039.0,13114579.0,94.9,51.1,5.88
|
|
||||||
Zimbabwe,24.645220000000002,22.0266,1286.0,13495462.0,98.3,47.3,3.85
|
|
|
File diff suppressed because one or more lines are too long
22
zadaniedomowe1/labs02/task07.py
Normal file
22
zadaniedomowe1/labs02/task07.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
Napisz funkcję char_sum, która dla zadanego łańcucha zwraca
|
||||||
|
sumę kodów ASCII znaków.
|
||||||
|
"""
|
||||||
|
def char_sum(text):
|
||||||
|
return sum(ord(i) for i in text)
|
||||||
|
|
||||||
|
def tests(f):
|
||||||
|
inputs = [["this is a string"], ["this is another string"]]
|
||||||
|
outputs = [1516, 2172]
|
||||||
|
|
||||||
|
for input, output in zip(inputs, outputs):
|
||||||
|
if f(*input) != output:
|
||||||
|
return "ERROR: {}!={}".format(f(*input), output)
|
||||||
|
break
|
||||||
|
return "TESTS PASSED"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(tests(char_sum))
|
29
zadaniedomowe1/labs02/task08.py
Normal file
29
zadaniedomowe1/labs02/task08.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
Napisz funkcję sum_div35(n), która zwraca sumę wszystkich liczb podzielnych
|
||||||
|
przez 3 lub 5 mniejszych niż n.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def sum_div35(n):
|
||||||
|
i, suma = 1, 0
|
||||||
|
for i in range(1, n):
|
||||||
|
if not (i % 3 and i % 5):
|
||||||
|
suma += i
|
||||||
|
i += 1
|
||||||
|
return suma
|
||||||
|
sum_div35(10)
|
||||||
|
|
||||||
|
def tests(f):
|
||||||
|
inputs = [[10], [100], [3845]]
|
||||||
|
outputs = [23, 2318, 3446403]
|
||||||
|
|
||||||
|
for input, output in zip(inputs, outputs):
|
||||||
|
if f(*input) != output:
|
||||||
|
return "ERROR: {}!={}".format(f(*input), output)
|
||||||
|
break
|
||||||
|
return "TESTS PASSED"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(tests(sum_div35))
|
25
zadaniedomowe1/labs02/task09.py
Normal file
25
zadaniedomowe1/labs02/task09.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
Napisz funkcję leet_speak, która podmienia w podanym napisie niektóre litery
|
||||||
|
na podobnie wyglądające cyfry: 'e' na '3', 'l' na '1', 'o' na '0', 't' na '7'.
|
||||||
|
Np. leet('leet') powinno zwrócić '1337'.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def leet_speak(tekst):
|
||||||
|
return tekst.replace('o', '0').replace('l', '1').replace('e', '3').replace('t', '7')
|
||||||
|
|
||||||
|
def tests(f):
|
||||||
|
inputs = [['leet'], ['do not want']]
|
||||||
|
outputs = ['1337', 'd0 n07 wan7']
|
||||||
|
|
||||||
|
for input, output in zip(inputs, outputs):
|
||||||
|
if f(*input) != output:
|
||||||
|
return "ERROR: {}!={}".format(f(*input), output)
|
||||||
|
break
|
||||||
|
return "TESTS PASSED"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(tests(leet_speak))
|
38
zadaniedomowe1/labs02/task10.py
Normal file
38
zadaniedomowe1/labs02/task10.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Napisz funkcję pokemon_speak, która zamienia w podanym napisie co drugą literę
|
||||||
|
na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def pokemon_speak(text):
|
||||||
|
value = ''
|
||||||
|
b = True
|
||||||
|
for i in text:
|
||||||
|
value += i.upper() if b else i.lower()
|
||||||
|
b = not b
|
||||||
|
if i.isupper() == True:
|
||||||
|
return text
|
||||||
|
else:
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
pokemon_speak('pokemon')
|
||||||
|
pokemon_speak('do not want')
|
||||||
|
pokemon_speak('POKEMON')
|
||||||
|
|
||||||
|
def tests(f):
|
||||||
|
inputs = [['pokemon'], ['do not want'], ['POKEMON']]
|
||||||
|
outputs = ['PoKeMoN', 'Do nOt wAnT', 'POKEMON']
|
||||||
|
|
||||||
|
for input, output in zip(inputs, outputs):
|
||||||
|
if f(*input) != output:
|
||||||
|
return "ERROR: {}!={}".format(f(*input), output)
|
||||||
|
break
|
||||||
|
return "TESTS PASSED"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(tests(pokemon_speak))
|
28
zadaniedomowe1/labs02/task11.py
Normal file
28
zadaniedomowe1/labs02/task11.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Napisz funkcję common_chars(string1, string2), która zwraca alfabetycznie
|
||||||
|
uporządkowaną listę wspólnych liter z lańcuchów string1 i string2.
|
||||||
|
Oba napisy będą składać się wyłacznie z małych liter.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def common_chars(string1, string2):
|
||||||
|
txt1 = string1.replace(' ','')
|
||||||
|
txt2 = string2.replace(' ','')
|
||||||
|
|
||||||
|
return list(''.join(sorted(set(txt1) & set(txt2))))
|
||||||
|
|
||||||
|
def tests(f):
|
||||||
|
inputs = [["this is a string", "ala ma kota"]]
|
||||||
|
outputs = [['a', 't']]
|
||||||
|
|
||||||
|
for input, output in zip(inputs, outputs):
|
||||||
|
if f(*input) != output:
|
||||||
|
return "ERROR: {}!={}".format(f(*input), output)
|
||||||
|
break
|
||||||
|
return "TESTS PASSED"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(tests(common_chars))
|
23
zadaniedomowe1/labs04/cwiczenie5.py
Normal file
23
zadaniedomowe1/labs04/cwiczenie5.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import glob
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
import pandas
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
bleu_files = glob.glob('./scores/model.iter*.npz.bleu')
|
||||||
|
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
for bleu_file in bleu_files:
|
||||||
|
|
||||||
|
lines += [[os.path.abspath(bleu_file), float(re.sub(r'.*?=\s*([^,]+).*', '\\1', line.rstrip('\n')))] for line in open(bleu_file)]
|
||||||
|
|
||||||
|
df = pandas.DataFrame(lines, columns=list('AB'))
|
||||||
|
|
||||||
|
print(df['A'].loc[df['B'].idxmax()])
|
BIN
zadaniedomowe2/zadaniedomowe2.rar
Normal file
BIN
zadaniedomowe2/zadaniedomowe2.rar
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user