-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmissionsvRealEstate.py
46 lines (40 loc) · 1.27 KB
/
EmissionsvRealEstate.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
import pandas as pd
from pandas import DataFrame, read_csv
import plotly
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
plotly.tools.set_credentials_file(username='RIGUN', api_key='8iuvw4lZc9zH9Ut6skoy')
df2 = pd.read_excel("emissions.xls")
df3 = pd.read_csv("Zip_MedianValuePerSqft_AllHomes.csv")
temp_list = []
Emission = 0
for i in df3["ZIP"]:
ZipCode = i
temp_df = df2.loc[df2["ZIP CODE"] == i]
if temp_df.empty:
continue
s = temp_df["GHG QUANTITY (METRIC TONS CO2e)"]
Emission = s.sum()
temp_df2 = df3.loc[df3["ZIP"] == i]
Cost = temp_df2.iat[0, 1]
temp_list.append([ZipCode, Emission, Cost])
df = pd.DataFrame(temp_list)
df.columns = ["ZipCode", "Emission", "Cost"]
trace = go.Scatter(
x = df["Emission"],
y = df["Cost"],
mode = 'markers'
)
data = [trace]
layout = dict(
title = 'Emissions (Metric Tons CO2) vs Median Residental Cost per Sqr Foot',
xaxis = dict(
title = 'Carbon Emissions (Metric Tons CO2)',
),
yaxis = dict(
title = 'Median Residential Cost per Sqr Foot',
)
)
fig = go.Figure(data = data, layout = layout)
py.iplot(fig, filename ='Emissions (Metric Tons CO2) vs Median Residental Cost per Sqr Foot')