zadanie domowe
This commit is contained in:
parent
adf2d4d587
commit
7f64a03469
@ -1,14 +1,19 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import pandas as pd
|
||||
from statistics import mode
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
def wczytaj_dane():
|
||||
pass
|
||||
r = pd.read_csv("mieszkania.csv")
|
||||
dane = r.dropna(axis='columns')
|
||||
return dane
|
||||
|
||||
def most_common_room_number(dane):
|
||||
pass
|
||||
return mode(dane.Rooms)
|
||||
|
||||
def cheapest_flats(dane, n):
|
||||
pass
|
||||
return dane.sort_values(by=["Expected"]).head(n)
|
||||
|
||||
def find_borough(desc):
|
||||
dzielnice = ['Stare Miasto',
|
||||
@ -19,23 +24,36 @@ def find_borough(desc):
|
||||
'Winogrady',
|
||||
'Miłostowo',
|
||||
'Dębiec']
|
||||
pass
|
||||
|
||||
indeks = len(desc)
|
||||
nazwa_dzielnicy = "Inne"
|
||||
for dzielnica in dzielnice:
|
||||
indeks_dzielnica = desc.find(dzielnica)
|
||||
if indeks_dzielnica < indeks and indeks_dzielnica != -1:
|
||||
indeks = indeks_dzielnica
|
||||
nazwa_dzielnicy = dzielnica
|
||||
return nazwa_dzielnicy
|
||||
|
||||
def add_borough(dane):
|
||||
pass
|
||||
dane['Borough'] = dane['Location'].apply(find_borough)
|
||||
return dane
|
||||
|
||||
def write_plot(dane, filename):
|
||||
pass
|
||||
add_borough(dane)
|
||||
dane_wykres = pd.Series(dane.Borough.value_counts())
|
||||
dane_wykres.plot(x='Borough', y='Liczba ogłoszeń', kind = 'bar')
|
||||
plt.savefig(filename, pad_inches=1, bbox_inches='tight')
|
||||
|
||||
def mean_price(dane, room_number):
|
||||
pass
|
||||
return dane.Expected[(dane['Rooms'] == room_number)].mean()
|
||||
|
||||
def find_13(dane):
|
||||
pass
|
||||
add_borough(dane)
|
||||
return dane.Borough[(dane['Floor'] == 13)].unique()
|
||||
|
||||
def find_best_flats(dane):
|
||||
pass
|
||||
add_borough(dane)
|
||||
return dane[(dane['Borough'] == 'Winogrady') & (dane['Rooms'] == 3) & (dane['Floor'] == 1)]
|
||||
|
||||
def main():
|
||||
dane = wczytaj_dane()
|
||||
@ -44,8 +62,8 @@ def main():
|
||||
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("{} to najładniejsza dzielnica w Poznaniu."
|
||||
.format(find_borough("Grunwald i Jeżyce")))
|
||||
|
||||
print("Średnia cena mieszkania 3-pokojowego, to: {}"
|
||||
.format(mean_price(dane, 3)))
|
||||
|
Loading…
Reference in New Issue
Block a user