-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisual.py
67 lines (55 loc) · 1.84 KB
/
visual.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import plotly.express as px
from process import ProcessedData
class VisualisedData(ProcessedData):
def __init__(self):
super().__init__()
# bar chart of average price by county (OUR DATA)
# from 2010 - 2019
visualised = VisualisedData()
df = visualised.cleaned_data
year = 2010
new = True # Change to False to get second hand values
data = []
'''
if new:
desc = "New"
suffix = ""
file_desc = "new"
else:
desc = "Second"
suffix = "Hand"
file_desc = "old"
for place in visualised.places_no_national:
our_averages_df = df[
(df['Year'] == year) & (df['County'] == place) & (df['Description'] == desc)
]
data.append([place, round(our_averages_df['Price'].mean())])
our_average = visualised.pd.DataFrame(data, columns=['Place', 'Average Price (€)'])
graph = px.bar(our_average, x="Place", y="Average Price (€)", color="Place", title=f"Our calculated averages for each county in {year} ({desc} {suffix})")
graph.write_html(f"average_{year}_{file_desc}.html", full_html=False, include_plotlyjs=False)
#graph.show()
'''
# bar chart of average price in specified year (GOV DATA)
# 1976 - 2016
year = 1980
new = True # Change to False to get second hand values
if new:
df = visualised.new_avg
else:
df = visualised.old_avg
data = []
if new:
desc = "New"
suffix = ""
file_desc = "new"
else:
desc = "Second"
suffix = "Hand"
file_desc = "old"
for place in visualised.places:
gov_average = df.loc[year, place]
data.append([place, round(gov_average)])
our_average = visualised.pd.DataFrame(data, columns=['Place', 'Average Price (€)'])
graph = px.bar(our_average, x="Place", y="Average Price (€)", color="Place", title=f"Government averages in {year} ({desc} {suffix})")
graph.write_html(f"gov_average_{year}_{file_desc}.html", full_html=False, include_plotlyjs=False)
#graph.show()