Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. import pandas
  2. """
  3. Utworzyłam 6 klas:
  4. - Place: kolumna longitude, latitude
  5. - Details: kolumna housing_median_age, total_rooms, total_bedrooms
  6. - Households: kolumna population, households
  7. - Profit: kolumna median_house_value, median_income
  8. - House: odwołująca się do obiektow poprzednich klas (tj. place, details, households, profit)
  9. - House_List: wypisuje wszystkie obiekty z klasy House
  10.  
  11. """
  12. readdata = pandas.read_csv('C:/Users/klaud/Desktop/WAT/sample_data/california_housing_test.csv');
  13.  
  14. class Place():
  15. longitude, latitude = 0, 0
  16.  
  17. def __init__(self, longitude, latitude):
  18. self.longitude = longitude
  19. self.latitude = latitude
  20.  
  21. def __str__(self):
  22. return (self.longitude, self.latitude)
  23.  
  24. class Details():
  25. total_rooms, median_age, total_bedrooms = 0, 0, 0
  26.  
  27. def __init__(self, median_age, total_rooms, total_bedrooms):
  28. self.median_age = median_age
  29. self.total_rooms = total_rooms
  30. self.total_bedrooms = total_bedrooms
  31.  
  32. def __str__(self):
  33. return (self.median_age, self.total_rooms, self.total_bedrooms)
  34.  
  35. class Households():
  36.  
  37. def __init__(self, population, households):
  38. self.population = population
  39. self.households = households
  40.  
  41. def __str__(self):
  42. return (self.population, self.households)
  43.  
  44. class Profit():
  45. house_value, income = 0, 0
  46.  
  47. def __init__(self, income, house_value):
  48. self.income = income
  49. self.house_value = house_value
  50.  
  51. def __str__(self):
  52. return (self.income, self.house_value)
  53.  
  54.  
  55. class House():
  56.  
  57. def __init__(self, place, details, household, profit):
  58. self.place = place
  59. self.details = details
  60. self.household = household
  61. self.profit = profit
  62.  
  63. def __str__(self):
  64. return (self.place, self.details, self.household, self.profit)
  65.  
  66. class House_List(
  67.  
  68. def __init__(self):
  69. self.list = list()
  70.  
  71. def print_list(self):
  72. # Dla kazdego naglowka pliku .csv
  73. print("longitude,latitude,housing_median_age,total_rooms,total_bedrooms,population,households,median_income,median_house_value")
  74. for i in self.list:
  75. print(i)
  76.  
  77. # Wypisz zawartosc listy
  78. houses = House_List()
  79. houses.print_list()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement