1
0
forked from tdwojak/Python2017

commited tasks

This commit is contained in:
s45150 2018-01-02 17:38:06 +01:00
parent 693f24077e
commit d6a66ea496

View File

@ -6,9 +6,7 @@ reload(sys)
sys.setdefaultencoding("utf-8") sys.setdefaultencoding("utf-8")
import pandas as pd import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
def wczytaj_dane(): def wczytaj_dane():
rooms_data = pd.read_csv('mieszkania.csv', # ścieżka do pliku rooms_data = pd.read_csv('mieszkania.csv', # ścieżka do pliku
@ -60,29 +58,11 @@ def add_borough(dane):
def write_plot(dane, filename): def write_plot(dane, filename):
add_borough(dane) add_borough(dane)
hist_data = dane['Borough'].value_counts() 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))
# plt.figure() fig = Hist_out.get_figure()
wyplot = hist_data.plot(kind='bar', alpha=0.5, title="Liczba ogloszen mieszkan z podzialem na dzielnice",
fontsize=5, figsize=(7, 5))
wyplot.set_xlabel("Dzielnice")
wyplot.set_ylabel("Liczba ogloszen")
# plt.show()
fig = wyplot.get_figure()
fig.savefig(filename) fig.savefig(filename)
def mean_price(dane, room_number): def mean_price(dane, room_number):
AVGdane = dane[dane.Rooms == room_number] AVGdane = dane[dane.Rooms == room_number]
AVGdane = round(AVGdane.Expected.mean(),2) AVGdane = round(AVGdane.Expected.mean(),2)
@ -90,10 +70,17 @@ def mean_price(dane, room_number):
def find_13(dane): def find_13(dane):
pass add_borough(dane)
List_13 = []
WhatLookFor = dane['Borough'].loc[dane['Floor'] == 13]
for j in WhatLookFor:
List_13.append(j)
return List_13
def find_best_flats(dane): def find_best_flats(dane):
pass add_borough(dane)
TheBest = dane[(dane.Borough == 'Winogrady') & (dane.Rooms == 3) & (dane.Floor == 1)]
return TheBest
def main(): def main():
dane = wczytaj_dane() dane = wczytaj_dane()
@ -110,7 +97,7 @@ def main():
.format(mean_price(dane, 3))) .format(mean_price(dane, 3)))
roomCheapest = cheapest_flats(dane, 5) roomCheapest = cheapest_flats(dane, 5)
#print roomCheapest print roomCheapest
district = add_borough(dane['Location']) district = add_borough(dane['Location'])
dane['Borough'] = district.values dane['Borough'] = district.values
@ -118,5 +105,12 @@ def main():
write_plot(dane, 'plot.png') write_plot(dane, 'plot.png')
list_13 = find_13(dane)
print list_13
TheBestFlat = find_best_flats(dane)
print TheBestFlat['Location']
if __name__ == "__main__": if __name__ == "__main__":
main() main()