#!/usr/bin/env python
# coding: utf-8
#
#
Are Morgan Hill CA Homes Increasing in Value or Decreasing in Value?
#
#
#
#
#
#
#
#
#
#
#
#
#
# Hello!
# I’m Mikaela Rojas!
#
#
# Thank you for choosing me as your South Bay Realtor! Let's take a
# a look at Morgan Hill CA home values.
#
#
#
#
#
# In[1]:
import pandas as pd
import matplotlib.pyplot as plt # only needed for advanced plotting
import matplotlib.dates as dates
plt.style.use('ggplot')
get_ipython().run_line_magic('matplotlib', 'inline')
# In[2]:
# grab Zillow data
# Morgan Hill,CA,San Jose,Santa Clara|01424
# FR = Percentage of Sales that were Foreclosures
df_iv = pd.read_csv('http://www.quandl.com/api/v3/datasets/ZILL/C01424_IV.csv')
df_dv = pd.read_csv('http://www.quandl.com/api/v3/datasets/ZILL/C01424_DV.csv')
df_iv.head();
# In[3]:
# convert to date format
df_iv['Date'] = pd.to_datetime(df_iv['Date'])
df_dv['Date'] = pd.to_datetime(df_dv['Date'])
# In[4]:
# rename columns
df_iv.columns = ['Date','num_increasing']
df_dv.columns = ['Date','num_decreasing']
# In[5]:
# set Date to be the index
df_iv = df_iv.set_index('Date')
df_dv = df_dv.set_index('Date')
# ## Good News! We currently have more homes increasing in value than in Jan 2016. We also have fewer home decreasing in value compared to Jauary 2016.
# In[6]:
# Advanced Plotting
####################
fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(13, 5))
fig.subplots_adjust(hspace=1.0) ## Create space between plots
# Chart 1
mask1 = df_iv.index.year >= 2016
df_iv[mask1].sort_index().plot.line(ax=axes)
# Chart 2
mask1 = df_dv.index.year >= 2016
df_dv[mask1].sort_index().plot.line(ax=axes, alpha=0.4, color='b')
# add a little sugar
axes.set_title('Number of Home Increasing or Decreasing in Value')
axes.set_ylabel('# of homes')
axes.legend(["# increasing","# decreasing"], loc='best');
#
#
#
# the information came from quandl and Zillow
#
# In[7]:
from IPython.display import HTML
HTML('''
''')