From d6a66ea4960ef88adb0d1af4e1ebd5c022450c0d Mon Sep 17 00:00:00 2001 From: s45150 Date: Tue, 2 Jan 2018 17:38:06 +0100 Subject: [PATCH] commited tasks --- labs06/task02.py | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/labs06/task02.py b/labs06/task02.py index 204e4c6..dd862c2 100755 --- a/labs06/task02.py +++ b/labs06/task02.py @@ -6,9 +6,7 @@ reload(sys) sys.setdefaultencoding("utf-8") import pandas as pd -import numpy as np -import matplotlib -import matplotlib.pyplot as plt + def wczytaj_dane(): rooms_data = pd.read_csv('mieszkania.csv', # ścieżka do pliku @@ -60,29 +58,11 @@ def add_borough(dane): def write_plot(dane, filename): add_borough(dane) - hist_data = dane['Borough'].value_counts() - - # plt.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() - + 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) - def mean_price(dane, room_number): AVGdane = dane[dane.Rooms == room_number] AVGdane = round(AVGdane.Expected.mean(),2) @@ -90,10 +70,17 @@ def mean_price(dane, room_number): 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): - pass + add_borough(dane) + TheBest = dane[(dane.Borough == 'Winogrady') & (dane.Rooms == 3) & (dane.Floor == 1)] + return TheBest def main(): dane = wczytaj_dane() @@ -110,7 +97,7 @@ def main(): .format(mean_price(dane, 3))) roomCheapest = cheapest_flats(dane, 5) - #print roomCheapest + print roomCheapest district = add_borough(dane['Location']) dane['Borough'] = district.values @@ -118,5 +105,12 @@ def main(): 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()