forked from tdwojak/Python2017
commit
This commit is contained in:
parent
40c98ed400
commit
9a66adcef5
@ -1,16 +1,19 @@
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
|
||||
def wczytaj_dane():
|
||||
mieszkania = pd.read_csv('mieszkania.csv',
|
||||
encoding='utf-8',
|
||||
sep=',',
|
||||
index_col='Id')
|
||||
return (mieszkania)
|
||||
return pd.DataFrame(mieszkania)
|
||||
|
||||
def most_common_room_number(dane):
|
||||
pass
|
||||
def most_common_room_number (dane):
|
||||
return dane['Rooms'].value_counts().head()
|
||||
|
||||
def cheapest_flats(dane, n):
|
||||
pass
|
||||
return dane.sort_values('Expected').head(n)
|
||||
|
||||
def find_borough(desc):
|
||||
dzielnice = ['Stare Miasto',
|
||||
@ -21,14 +24,21 @@ def find_borough(desc):
|
||||
'Winogrady',
|
||||
'Miłostowo',
|
||||
'Dębiec']
|
||||
pass
|
||||
|
||||
for dzielnica in dzielnice:
|
||||
if dzielnica in desc:
|
||||
return dzielnica
|
||||
return 'Inne'
|
||||
|
||||
def add_borough(dane):
|
||||
pass
|
||||
dane['Borough'] = dane['Location'].apply(find_borough)
|
||||
return dane
|
||||
|
||||
def write_plot(dane, filename):
|
||||
pass
|
||||
data = add_borough(dane)
|
||||
plot_data = data['Borough'].value_counts()
|
||||
plot_data.plot( Kind = 'bar',title='Mieszkania z podziałem na dzielnice')
|
||||
figure_data = plot_data.get_figure()
|
||||
figure_data.savefig ( filename )
|
||||
|
||||
def mean_price(dane, room_number):
|
||||
pass
|
||||
@ -43,14 +53,12 @@ def main():
|
||||
dane = wczytaj_dane()
|
||||
print(dane[:5])
|
||||
|
||||
print("Najpopularniejsza liczba pokoi w mieszkaniu to: {}"
|
||||
.format(most_common_room_number(dane)))
|
||||
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("Najtańsze mieszkania, to: {}".format(cheapest_flats(dane, 5)))
|
||||
|
||||
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)))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue
Block a user