Created
October 20, 2019 16:25
-
-
Save johnathaningle/c0f7a9303d51afc1cb3136a94f24de85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.graph_objs as go | |
import pandas as pd | |
import numpy as np | |
df = pd.read_csv("Real Estate Data YOY .csv") | |
print(df.head()) | |
i = 0 | |
cols = [col for col in df.columns] | |
cols = cols[1:] | |
for col in cols: | |
fig = go.Figure(data=go.Choropleth( | |
locations=df['State'], # Spatial coordinates | |
z = df[col].astype(float), # Data to be color-coded | |
locationmode = 'USA-states', # set of locations match entries in `locations` | |
colorscale = 'viridis', | |
showscale=True, | |
)) | |
fig.update_layout( | |
title_text = 'Percent Change In Sales Price - ' + str(col), | |
geo_scope='usa', # limite map scope to USA | |
) | |
fig.write_image(f"delta{i}.png", width=1920, height=1080) | |
i += 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment