1
0
forked from tdwojak/Python2017

Compare commits

..

11 Commits

Author SHA1 Message Date
a0fecba5c4 Final updates 2018-01-29 12:22:18 +01:00
26afa652a5 update 2018-01-24 10:26:29 +01:00
f61d161938 update results 2018-01-23 22:34:37 +01:00
5d25e165c4 Update 45163 2018-01-23 22:05:16 +01:00
dc5fb3f34b Add marks 2018-01-23 17:19:50 +01:00
fd67d4b96f Add task06 2018-01-23 16:54:47 +01:00
1599eb71ba update szwedek 2018-01-22 15:42:47 +01:00
524eefe436 Update scores for 45161 2018-01-19 08:50:18 +01:00
7ef244fb88 Fix socres for 147 2018-01-18 17:41:40 +01:00
d8025c91ff Add missed results 2018-01-15 11:11:11 +01:00
378fee7582 Update results 2018-01-11 13:41:08 +01:00
25 changed files with 75 additions and 422 deletions

View File

@ -1,24 +1,38 @@
ID | labs02:task07 | labs02:task08 | labs02:task09 | labs02:task10 | labs02:task11
---------|-----------------|-----------------|-----------------|-----------------|---------------
s45168 | 0 | 0 | 0 | 0 | 0
s45162 | 1 | 1 | 1 | 1 | 1
s45158 | 1 | 1 | 0 | 0 | 1
szwedek | 1 | 1 | 1 | 1 | 1
s45155 | 1 | 1 | 1 | 1 | 1
s45152 | 1 | 1 | 1 | 0 | 1
s45148 | 1 | 1 | 1 | 1 | 1
s45166 | 1 | 1 | 1 | 1 | 1
s45151 | 1 | 1 | 1 | 1 | 1
s45146 | 1 | 1 | 1 | 1 | 1
s45150 | 1 | 1 | 1 | 1 | 1
s45452 | 1 | 1 | 1 | 1 | 1
s45165 | 1 | 1 | 1 | 1 | 1
s45160 | 1 | 1 | 1 | 1 | 1
s45153 | 0 | 0 | 0 | 0 | 0
s45156 | 1 | 1 | 1 | 1 | 1
s45157 | 0 | 0 | 1 | 1 | 1
s45167 | 1 | 1 | 1 | 1 | 1
s45147 | 1 | 0 | 0 | 1 | 0
s45159 | 0 | 0 | 0 | 0 | 0
s45161 | 1 | 1 | 1 | 1 | 1
s45164 | 1 | 1 | 0 | 1 | 0
ID | labs02:task07 | labs02:task08 | labs02:task09 | labs02:task10 | labs02:task11 | labs03 | labs04 | labs06 | Punkty | Ocena |
---------|-----------------|-----------------|-----------------|-----------------|-----------------|----------|----------|----------|--------|-------|
s45146 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45147 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45148 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45150 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 8 | 16 | 4 |
s45151 | 1 | 1 | 1 | 1 | 1 | 0 | 5 | 8 | 18 | 4.5 |
s45152 | 1 | 1 | 1 | 0 | 1 | 0 | 5 | 8 | 17 | 4 |
s45153 | 0 | 1 | 1 | 1 | 1 | 4 | 0 | 8 | 16 | 4 |
s45155 | 1 | 1 | 1 | 1 | 1 | 1 | 5 | 8 | 19 | 4.5 |
s45156 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45157 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
s45158 | 1 | 1 | 0 | 0 | 1 | 4 | 5 | 8 | 19 | 4.5 |
s45159 | 1 | 1 | 1 | 1 | 1 | 2 | 3 | 8 | 18 | 4.5 |
s45160 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
s45161 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45162 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45163 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
s45164 | 1 | 1 | 0 | 1 | 0 | 0 | 5 | 8 | 16 | 4 |
s45165 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45166 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
s45167 | 1 | 1 | 1 | 1 | 1 | 0 | 5 | 8 | 17 | 4 |
s45168 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
s45452 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
szwedek | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 10 | 24 | 5 |
Skala:
Punkty | Ocena |
-------|-------|
24-20 | 5 |
19-18 | 4.5 |
17-16 | 4 |
15-13 | 3 |
12-0 | 2 |
Max: 22

View File

@ -7,7 +7,7 @@ która zawiera tylko elementy z list o parzystych indeksach.
"""
def even_elements(lista):
return lista[::2]
pass
def tests(f):

View File

@ -5,11 +5,8 @@
Napisz funkcję days_in_year zwracającą liczbę dni w roku (365 albo 366).
"""
def days_in_year(year):
if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0):
return 366
else:
return 365
def days_in_year(days):
pass
def tests(f):
inputs = [[2015], [2012], [1900], [2400], [1977]]

View File

@ -13,12 +13,7 @@ jak 'set', która przechowuje elementy bez powtórzeń.)
def oov(text, vocab):
test_list = []
_textSPlit =text.split(" ")
for i in _textSPlit:
if i not in vocab:
test_list.append(i)
return test_list
pass

View File

@ -7,13 +7,7 @@ Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0.
"""
def sum_from_one_to_n(n):
if n < 0:
return 0
else:
x = 0
for i in range(n+1):
x = x + i
return x
pass
def tests(f):

View File

@ -10,11 +10,7 @@ np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5.
"""
def euclidean_distance(x, y):
dist = 0
for i in range(len(x)):
dist += (x[i]-y[i])**2
dist = dist**0.5
return dist
pass
def tests(f):
inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]]

View File

@ -10,14 +10,7 @@ ma być zwracany napis "It's not a Big 'No!'".
"""
def big_no(n):
if n < 5:
out = "It's not a Big 'No!'"
else:
out = "N"
for i in range(n):
out += "O"
out += "!"
return out
pass
def tests(f):
inputs = [[5], [6], [2]]

View File

@ -6,12 +6,7 @@ Napisz funkcję char_sum, która dla zadanego łańcucha zwraca
sumę kodów ASCII znaków.
"""
def char_sum(text):
sumaAsci = 0
text_tmp = text
for i in text_tmp:
sumaAsci += ord(i)
return sumaAsci
pass
def tests(f):
inputs = [["this is a string"], ["this is another string"]]

View File

@ -7,13 +7,7 @@ przez 3 lub 5 mniejszych niż n.
"""
def sum_div35(n):
suma = 0
i = 0
while i < n:
if i%3 == 0 or i%5 == 0:
suma += i
i += 1
return suma
pass
def tests(f):
inputs = [[10], [100], [3845]]

View File

@ -9,20 +9,8 @@ Np. leet('leet') powinno zwrócić '1337'.
def leet_speak(text):
text_tmp = text
lista_temp = ""
for i in text_tmp:
if i =='e':
lista_temp += '3'
elif i =='l':
lista_temp += '1'
elif i =='o':
lista_temp += '0'
elif i =='t':
lista_temp +='7'
else:
lista_temp +=i
return lista_temp
pass
def tests(f):
inputs = [['leet'], ['do not want']]

View File

@ -9,23 +9,7 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
def pokemon_speak(text):
#spacja Asci 32
lista_temp = ""
j = 1
for i in text:
if ord(i) == 32:
j=1
lista_temp += i
else:
if j%2 == 0:
lista_temp += i
else:
lista_temp += i.upper()
j += 1
return lista_temp
pass
def tests(f):

View File

@ -9,21 +9,7 @@ Oba napisy będą składać się wyłacznie z małych liter.
"""
def common_chars(string1, string2):
string1=''.join(sorted(string1))
string1 = string1.strip(' ')
#print string1
string2 = ''.join(sorted(string2))
string2 = string2.strip(' ')
#print string2
slist = list()
for char in string1:
count=string2.count(char)
if count > 0:
if char not in slist:
slist.append(char)
#print(slist)
return(slist)
pass
def tests(f):

View File

@ -232,13 +232,13 @@
{
"ename": "TypeError",
"evalue": "unhashable type: 'list'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-25-2bd2fa17fbf5>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mt\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mt\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0mt\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: unhashable type: 'list'"
],
"output_type": "error"
]
}
],
"source": [
@ -398,13 +398,13 @@
{
"ename": "ValueError",
"evalue": "I/O operation on closed file.",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-47-f06513c1bbec>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mlinia\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mplik\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreadlines\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlinia\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mplik\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mValueError\u001b[0m: I/O operation on closed file."
],
"output_type": "error"
]
}
],
"source": [

View File

@ -1,4 +0,0 @@
print(id(2))
print(id("Ala ma kotA"))
print(id([1, 3, 11]))

View File

@ -1,15 +0,0 @@
#task02
#Fibonacci
def fibonacci(n):
if n <= 1:
return n
else:
return fibonacci(n-2) + fibonacci(n-1)
print(fibonacci(0))
print(fibonacci(1))
print(fibonacci(2))
print(fibonacci(3))
print(fibonacci(4))
print(fibonacci(20))

View File

@ -1,16 +0,0 @@
#task 03
import requests
url = "https://api.fixer.io/latest"
response = requests.get(url)
ALLData = response.json()
CurrancyPLN = ALLData['rates']
print("Kurs EURO: {} PLN".format(CurrancyPLN['PLN']))

View File

@ -1,55 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
**ćwiczenie 4**
Zainstaluj bibliotekę ``weather-api`` (https://pypi.python.org/pypi/weather-api). Korzystając z niej:
* Wypisz informacje o aktualnej pogodzie.
* Napisz funkcję, która zamieni stopnie ``F`` na ``C``.
* Korzystając z prognozy, znajdź dzień, w którym będzie najzimniej. Wypisz nazwę tygodnia (w języku polskim) i temperaturę w C.
"""
#task04
from weather import Weather
DD = {'Mon':'Poniedziałek','Tue':'Poniedziałek','Wed':'Środa','Thu':'Czwartek','Fri':'Piątek','Sat':'Sobota','Sun':'Niedziela'}
MM = {'Jan':'Styczeń','Feb':'Luty','Mar':'Marzec','Apr':'Kwiecień','May':'Maj','Jun':'Czerwiec','Jul':'Lipiec','Aug':'Sierpień','Sep':'Wrzesień','Oct':'Październik','Nov':'Listopad','Dec':'Grudzień'}
def ConvertF_TO_C (F):
conF = round((float(F) - 32) / 1.8,1)
return conF
weather = Weather()
miasto ='Poznań'
location = weather.lookup_by_location(miasto)
condition = location.condition()
OgolnieP = condition.text()
dataP = condition.date()
TempC = ConvertF_TO_C(condition.temp())
ddayD=dataP.split(',')[0]
dday=dataP.split(' ')[1]
MMonth=dataP.split(' ')[2]
YYYY=dataP.split(' ')[3]
print"Data = ", dday, '-',MM[MMonth], '-', YYYY, " ", DD[ddayD]
print "Pogoda ogólnie (ang.) = ", OgolnieP
print "Temperatura = ", TempC, " C"
forcst = location.forecast()
tmin = condition.temp()
dmin = condition.date()
for fc in forcst:
if fc.low() < tmin:
dmin = fc.date()
tmin = fc.low()
print("Prognoza:")
dmin = dmin.split(' ')
MMonth=dmin[1]
print "Min temp: ", tmin, " C"
print "W dniu: ",dmin[0] , "-",MM[MMonth] ,'-', dmin[2]

View File

@ -1,28 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#task05
import os
import glob
BLEUValue = 0
BLEUFileMax = ''
for Fname in glob.glob(os.getcwd() + '\scores\*.bleu'):
with open(Fname, 'r') as fp:
#print(fp.name)
for lineFile in fp:
iList=lineFile
iList= iList.split(',')
#print(iList)
BLEUValueTmp = iList[0][7:]
BLEUValueTmp = float(BLEUValueTmp)
#print(BLEUValueTmp)
if BLEUValueTmp > BLEUValue:
BLEUValue = BLEUValueTmp
BLEUFileMax = fp.name
fp.close
print "Max:", BLEUValue
print "File Name: ", BLEUFileMax

View File

@ -309,13 +309,13 @@
{
"ename": "AttributeError",
"evalue": "'Parser' object has no attribute '__parse'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-6-80ee186598d3>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mparser\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mParser\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mparser\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0mparser\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__parse\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m: 'Parser' object has no attribute '__parse'"
],
"output_type": "error"
]
}
],
"source": [
@ -465,13 +465,13 @@
{
"ename": "FileNotFoundError",
"evalue": "[Errno 2] No such file or directory: 'nieistniejący_plik.txt'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-20-41928d542bef>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"nieistniejący_plik.txt\"\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mplik\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mplik\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'nieistniejący_plik.txt'"
],
"output_type": "error"
]
}
],
"source": [
@ -614,13 +614,13 @@
{
"ename": "MyError",
"evalue": "Coś poszło nie tak!",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mMyError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-36-4fb306b42ebc>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mMyError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Coś poszło nie tak!\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mMyError\u001b[0m: Coś poszło nie tak!"
],
"output_type": "error"
]
}
],
"source": [

View File

@ -1,11 +1,3 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
def isNumeric(x):
for i in range(len(x)):
if isinstance(x[i], (int , float ))==False:
return False
return True
print(isNumeric([1,4,4.8,1]))

View File

@ -1,58 +1,3 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
class Employee:
id_prac = 0
def __init__ (self,imie, nazwisko):
Employee.id_prac += 1
self.imie = imie
self.nazwisko = nazwisko
self.id_prac = Employee.id_prac
def get_id (self):
return self.id_prac
class Recruiter (Employee):
def __int__(self,imieR, nazwiskoR):
Employee.__init__(self,imieR, nazwiskoR)
self.recruited=[]
def recruit(self,id):
self.recruited.append(id)
def __str__(self):
return '<Rekruter %s,%s,%s>' % (self.imieR, self.nazwiskoR, self.recruited)
class Programmer(Recruiter):
def __int__(self,imieP,nazwiskoP,rekruter):
Recruiter.__init__(self,imieP,nazwiskoP)
Recruiter.id_prac = rekruter
def __str__(self):
return '<Programista %s,%s, został zrekrutowany przez rekrutera o ID = >' % (self.imieP, self.nazwiskoP, Recruiter.id_prac)
prac1 = Employee("X1","Y1")
prac2 = Employee("X2","Y2")
prac3 = Employee("XY","Y3")
print(prac1.get_id())
print(prac2.get_id())
print(prac3.get_id())
print(Employee.id_prac )
prac4 = Recruiter('Rek1', 'RekN1')
print(prac4.imie)
print(prac4.nazwisko)
print(prac4.id_prac)
#to mi jeszcze nie działa
#prac5 = Programmer('Bozena','Bozeniasta', 4)
#print(prac5.imie)
#print(prac5.nazwisko)
#print(prac5.id_prac)
#print(prac5.get_id())

View File

@ -1,28 +1,3 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
class DimensionError(Exception):
def __init__(self):
super().__init__(self)
self.msg = 'Błąd !!!'
class Point():
def __int__(self,wspolrzedne):
if self.isNumeric(wspolrzedne):
self.wspolrzedne = wspolrzedne
else:
self.wspolrzedne = None
def isNumeric(x):
for i in range(len(x)):
if isinstance(x[i], (int, float)) == False:
return False
return True
pkt1 = Point([1, 1, 1])
pkt2 = Point([3, 3, 3])

View File

@ -2,10 +2,10 @@
# -*- coding: utf-8 -*-
def suma(liczby):
return sum(liczby)
pass
def main():
print(suma([1, 2, 3, 4]))
print(summa([1, 2, 3, 4]))
if __name__ == "__main__":
main()

View File

@ -1,15 +0,0 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import task00
import sys
def main():
print(sys.argv)
task00.suma()
if __name__ == "__main__":
main()

View File

@ -1,38 +1,14 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import pandas as pd
def wczytaj_dane():
rooms_data = pd.read_csv('mieszkania.csv', # ścieżka do pliku
sep=',', # separator
encoding='utf-8', # kodowanie
index_col='Id') # ustawienie indeksu na kolumnę Date
return rooms_data
pass
def most_common_room_number(dane):
d=dane['Rooms']
d= d.value_counts()
j=0
"""
for i in d:
print d.index[j] , i
j +=1
"""
d = d.index[0]
return d
pass
def cheapest_flats(dane, n):
SortDane = dane.sort_values('Expected',ascending=True)
PriceCheapest = SortDane['Expected']
PriceCheapest = PriceCheapest.head(n)
return PriceCheapest
pass
def find_borough(desc):
dzielnice = ['Stare Miasto',
@ -43,74 +19,36 @@ def find_borough(desc):
'Winogrady',
'Miłostowo',
'Dębiec']
for district in dzielnice:
if district in desc: return district
return 'Inne'
pass
def add_borough(dane):
boroughArr = []
for current_location in dane:
findborough = find_borough(current_location)
#print current_location , findborough
boroughArr.append(findborough)
return pd.Series(boroughArr)
pass
def write_plot(dane, filename):
add_borough(dane)
hist_data = dane['Borough'].value_counts()
Hist_out = hist_data.plot(kind='bar', alpha=0.5, title="Appartments in Distrinct",fontsize=5, figsize=(7, 5))
fig = Hist_out.get_figure()
fig.savefig(filename)
pass
def mean_price(dane, room_number):
AVGdane = dane[dane.Rooms == room_number]
AVGdane = round(AVGdane.Expected.mean(),2)
return AVGdane
pass
def find_13(dane):
add_borough(dane)
List_13 = []
WhatLookFor = dane['Borough'].loc[dane['Floor'] == 13]
for j in WhatLookFor:
List_13.append(j)
return List_13
pass
def find_best_flats(dane):
add_borough(dane)
TheBest = dane[(dane.Borough == 'Winogrady') & (dane.Rooms == 3) & (dane.Floor == 1)]
return TheBest
pass
def main():
dane = wczytaj_dane()
#print(dane[:5])
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")))
.format(find_borough("Grunwald i Jeżyce"))))
print("Średnia cena mieszkania 3-pokojowego, to: {}"
.format(mean_price(dane, 3)))
roomCheapest = cheapest_flats(dane, 5)
print roomCheapest
district = add_borough(dane['Location'])
dane['Borough'] = district.values
#print(dane[:5])
write_plot(dane, 'plot.png')
list_13 = find_13(dane)
print list_13
TheBestFlat = find_best_flats(dane)
print TheBestFlat['Location']
if __name__ == "__main__":
main()