From 8ba0a6d6129eea32c90a1b2c13278230f5afb7f3 Mon Sep 17 00:00:00 2001 From: s45159 Date: Sun, 21 Jan 2018 00:47:49 +0100 Subject: [PATCH] commit --- labs06/task02.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/labs06/task02.py b/labs06/task02.py index 013bfa6..1be57c4 100755 --- a/labs06/task02.py +++ b/labs06/task02.py @@ -10,10 +10,12 @@ def wczytaj_dane(): return pd.DataFrame(mieszkania) def most_common_room_number (dane): - return dane['Rooms'].value_counts().head() + most_common = dane['Rooms'].value_counts().head() + return most_common def cheapest_flats(dane, n): - return dane.sort_values('Expected').head(n) + cheapest = dane.sort_values('Expected').head(n) + return cheapest def find_borough(desc): dzielnice = ['Stare Miasto', @@ -41,24 +43,33 @@ def write_plot(dane, filename): figure_data.savefig ( filename ) def mean_price(dane, room_number): - pass + rooms = dane[ dane['Rooms']==room_number]['Expected'].mean() + return rooms def find_13(dane): - pass + floor_13 = dane[dane['Floor'] == 13]['Borough'].values + return floor_13 def find_best_flats(dane): - pass + best_flats = dane[(dane['Borough'] == 'Winogrady') & (dane['Rooms'] == 3) & (dane['Floor'] == 1)] + return best_flats -def main(): - dane = wczytaj_dane() - print(dane[:5]) +def main ( ): + dane = wczytaj_dane ( ) + print(dane[ :5 ]) print("Najpopularniejsza liczba pokoi w mieszkaniu to: {}".format ( most_common_room_number ( dane ) )) - print("Najtańsze mieszkania, to: {}".format(cheapest_flats(dane, 5))) + print("{} to najłądniejsza dzielnica w Poznaniu.".format ( find_borough ( "Grunwald i Jeżyce" ) )) - print("{} to najłądniejsza dzielnica w Poznaniu.".format(find_borough("Grunwald i Jeżyce"))) + print("Średnia cena mieszkania 3-pokojowego, to: {:.2f}".format ( mean_price ( dane , 3 ) )) + + dane = add_borough(dane) + + print("Dzielnice z ofertami na 13 pietrze: {}".format ( find_13 ( dane ) )) + + print("Najlepsze oferty: {}".format ( find_best_flats ( dane ) )) if __name__ == "__main__": - main() \ No newline at end of file + main ( ) \ No newline at end of file