forked from tdwojak/Python2018
Usuń 'task02.py'
This commit is contained in:
parent
c5543322de
commit
0fa75f61e7
55
task02.py
55
task02.py
@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
def wczytaj_dane():
|
||||
return pd.read_csv('mieszkania.csv')
|
||||
|
||||
def most_common_room_number(dane):
|
||||
return dane['Rooms'].mode()[0]
|
||||
|
||||
def cheapest_flats(dane, n):
|
||||
return dane.sort_values('Expected', axis=0, ascending=True)[:n]
|
||||
|
||||
def find_borough(desc):
|
||||
dzielnice = ['Stare Miasto',
|
||||
'Wilda',
|
||||
'Jeżyce',
|
||||
'Rataje',
|
||||
'Piątkowo',
|
||||
'Winogrady',
|
||||
'Miłostowo',
|
||||
'Dębiec']
|
||||
for dzielnica in dzielnice:
|
||||
if dzielnica in desc:
|
||||
return dzielnica
|
||||
return 'Inne'
|
||||
|
||||
|
||||
def add_borough(dane):
|
||||
dane['Borough'] = dane['Location'].apply(find_borough)
|
||||
|
||||
def write_plot(dane, filename):
|
||||
# TODO
|
||||
pass
|
||||
|
||||
def mean_price(dane, room_number):
|
||||
return dane[dane['Rooms'] == room_number]['Expected'].mean()
|
||||
|
||||
def find_13(dane):
|
||||
return dane[dane['Floor'] == 13]['Borough'].unique()
|
||||
|
||||
def find_best_flats(dane):
|
||||
return dane[(dane['Borough'] == 'Winogrady') & (dane['Floor'] == 1) & (dane['Rooms'] == 3)]
|
||||
|
||||
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)))
|
Loading…
Reference in New Issue
Block a user