forked from tdwojak/Python2018
zadanie
This commit is contained in:
parent
04cc66810a
commit
3624beaac4
35
labs06/task02.py
Executable file → Normal file
35
labs06/task02.py
Executable file → Normal file
@ -1,15 +1,19 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
def wczytaj_dane():
|
def wczytaj_dane():
|
||||||
pass
|
dane = pd.read_csv("./mieszkania.csv")
|
||||||
|
return dane
|
||||||
|
|
||||||
def most_common_room_number(dane):
|
def most_common_room_number(dane):
|
||||||
pass
|
return dane.Rooms.value_counts().idxmax()
|
||||||
|
|
||||||
def cheapest_flats(dane, n):
|
def cheapest_flats(dane, n):
|
||||||
pass
|
return dane.sort('Expected').head(n)
|
||||||
|
|
||||||
def find_borough(desc):
|
def find_borough(desc):
|
||||||
dzielnice = ['Stare Miasto',
|
dzielnice = ['Stare Miasto',
|
||||||
'Wilda',
|
'Wilda',
|
||||||
@ -19,23 +23,30 @@ def find_borough(desc):
|
|||||||
'Winogrady',
|
'Winogrady',
|
||||||
'Miłostowo',
|
'Miłostowo',
|
||||||
'Dębiec']
|
'Dębiec']
|
||||||
pass
|
for dzielnica in dzielnice:
|
||||||
|
list = desc.split(' ')
|
||||||
|
for element in list:
|
||||||
|
if len(element) > 2 and element == dzielnica:
|
||||||
|
return dzielnica
|
||||||
|
break
|
||||||
|
return "Inne"
|
||||||
|
|
||||||
def add_borough(dane):
|
def add_borough(dane):
|
||||||
pass
|
dane['Borough'] = dane['Location'].apply(find_borough)
|
||||||
|
return dane
|
||||||
|
|
||||||
def write_plot(dane, filename):
|
def write_plot(dane, filename):
|
||||||
pass
|
dane['Borough'].value_counts().plot.bar().get_figure().savefig(filename)
|
||||||
|
|
||||||
def mean_price(dane, room_number):
|
def mean_price(dane, room_number):
|
||||||
pass
|
mean_price = dane.Expected[(dane['Rooms'] == room_number)]
|
||||||
|
return mean_price.mean()
|
||||||
|
|
||||||
def find_13(dane):
|
def find_13(dane):
|
||||||
pass
|
return dane.Location[(dane['Floor'] == 13)].unique()
|
||||||
|
|
||||||
def find_best_flats(dane):
|
def find_best_flats(dane):
|
||||||
pass
|
return dane[(dane['Location'] == 'Winogrady') & (dane['Rooms'] == 3) & (dane['Floor'] == 1)]
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
dane = wczytaj_dane()
|
dane = wczytaj_dane()
|
||||||
@ -45,7 +56,7 @@ def main():
|
|||||||
.format(most_common_room_number(dane)))
|
.format(most_common_room_number(dane)))
|
||||||
|
|
||||||
print("{} to najłądniejsza dzielnica w Poznaniu."
|
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: {}"
|
print("Średnia cena mieszkania 3-pokojowego, to: {}"
|
||||||
.format(mean_price(dane, 3)))
|
.format(mean_price(dane, 3)))
|
||||||
|
Loading…
Reference in New Issue
Block a user