forked from tdwojak/Python2017
85 lines
1.9 KiB
Python
Executable File
85 lines
1.9 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
import pandas as pd
|
|
import numpy as np
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
def cheapest_flats(dane, n):
|
|
SortDane = dane.sort_values('Expected',ascending=True)
|
|
PriceCheapest = SortDane['Expected']
|
|
PriceCheapest = PriceCheapest.head(n)
|
|
return PriceCheapest
|
|
|
|
def find_borough(desc):
|
|
dzielnice = ['Stare Miasto',
|
|
'Wilda',
|
|
'Jeżyce',
|
|
'Rataje',
|
|
'Piątkowo',
|
|
'Winogrady',
|
|
'Miłostowo',
|
|
'Dębiec']
|
|
for district in dzielnice:
|
|
if district in desc: return district
|
|
return 'Inne'
|
|
|
|
|
|
def add_borough(dane):
|
|
pass
|
|
|
|
def write_plot(dane, filename):
|
|
pass
|
|
|
|
def mean_price(dane, room_number):
|
|
AVGdane = dane[dane.Rooms == room_number]
|
|
AVGdane = round(AVGdane.Expected.mean(),2)
|
|
return AVGdane
|
|
|
|
|
|
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)))
|
|
|
|
roomCheapest = cheapest_flats(dane, 5)
|
|
#print roomCheapest
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|