Python2018/labs06/task02.py

66 lines
1.4 KiB
Python
Raw Normal View History

2018-06-03 10:04:16 +02:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def wczytaj_dane():
2018-06-03 12:34:25 +02:00
import pandas as pd
dane = pd.read_csv("labs06/mieszkania.csv")
dane.head()
2018-06-03 10:04:16 +02:00
def most_common_room_number(dane):
2018-06-03 12:34:25 +02:00
dane['Rooms'].value_counts().idxmax()
2018-06-03 10:04:16 +02:00
def cheapest_flats(dane, n):
2018-06-03 20:24:02 +02:00
p = dane.sort_values(['Expected'], ascending=[0])
p.head(7)
2018-06-03 10:04:16 +02:00
def find_borough(desc):
dzielnice = ['Stare Miasto',
'Wilda',
'Jeżyce',
'Rataje',
'Piątkowo',
'Winogrady',
'Miłostowo',
'Dębiec']
pass
def add_borough(dane):
pass
def write_plot(dane, filename):
pass
def mean_price(dane, room_number):
2018-06-03 20:24:02 +02:00
p1 = dane[dane['Rooms'] == 2]
p2 = p1['Expected']
p2.mean()
2018-06-03 10:04:16 +02:00
def find_13(dane):
2018-06-03 20:24:02 +02:00
p1 = dane[dane['Floor'] == 13]
p1.Location.unique()
2018-06-03 10:04:16 +02:00
def find_best_flats(dane):
2018-06-03 20:24:02 +02:00
p_index = dane['Location'].str.contains('Winogrady')
p = dane[p_index]
p[(p['Rooms'] == 3) & (p['Floor'] == 1)]
2018-06-03 10:04:16 +02:00
def main():
dane = wczytaj_dane()
print(dane[:5])
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("Średnia cena mieszkania 3-pokojowego, to: {}"
.format(mean_price(dane, 3)))
if __name__ == "__main__":
main()