# !pip install fbprophet
%matplotlib inline
import pandas as pd
from fbprophet import Prophet
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
df = pd.read_csv('https://raw.githubusercontent.com/danielcaraway/data/master/Zip_Zhvi_SingleFamilyResidence.csv', encoding='latin')
hs = df[df['Metro'].str.contains('Hot Springs', na=False)]
lr = df[df['Metro'].str.contains('Little Rock', na=False)]
f = df[df['Metro'].str.contains('Fayetteville', na=False)]
s = df[df['Metro'].str.contains('Searcy', na=False)]
def graph_prices_for(df, location_name):
df_t = df.loc[:, '1996-04'::].T
df_t['avg'] = df_t.mean(numeric_only=True, axis=1)
df_t.reset_index(inplace=True)
columns = ['index', 'avg']
df = pd.DataFrame(df_t, columns = columns)
df = df.rename(index=str, columns={"avg": "y", "index": "ds"})
ax = df.set_index('ds').plot(figsize=(12, 8))
ax.set_ylabel('Home Prices in ' + location_name)
ax.set_xlabel('Date')
plt.show()
graph_prices_for(hs, "Hot Springs")
graph_prices_for(lr, "Little Rock")
graph_prices_for(f, "Fayetteville")
graph_prices_for(s, "Searcy")