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