Market Area Analysis - Detroit

We are going to explore price changes in the property and analyze how the price has changed with respect to the property tax, income by location, housing size and also considering other contributing factors like commute time, local business. Later on, we will correlate the prices with major cities and smaller cities in the US.

There are 14 columns in first dataset (1999-03-01 to 2017-06-01) - 'All Homes', 'Single Family Residance', 'Middle Tier', 'Bottom Tier', 'Condominium', '5 bedroom_more', '4 bedroom', '3 bedroom', '2 bedroom', '1 bedroom', 'Turnover All Homes', 'Pct Of Home increasing Values All Homes', 'Pct Of Home Decreasing Values All Homes','Median Value Per SqrFt All Homes'

AND 9 columns in Second DataFrame (2010-11-01 to 2017-06-01) - 'Price to rent ratio all Homes', 'Pct of Listing Price Reduction single Family Residance', 'Pct of Listing Price Reduction Condominum', 'Pct of Listing Price Reduction All Homes', 'Per sqr fit All Homes', 'Median Sold Price All Homes', 'Median Pct Of Price Reduction Single Family Residance', 'Median Price Cut Dollar All Homes', 'Price Cut Seas Adj All Homes'

Further I will be exploring with respect to other cities, stock market, government policies, and modeling for home pricing.

First of all import all required lIbaries

In [47]:
# import
import pandas as pd
import numpy as np
import requests
import matplotlib.pyplot as plt
import seaborn as sns
from scipy import stats
from scipy.stats import norm
from bokeh.plotting import figure
from bokeh.charts import Bar
from bokeh.io import output_file, show
from sklearn.preprocessing import StandardScaler
import warnings
warnings.filterwarnings('ignore')
%matplotlib inline
In [4]:
Mortage_Data = pd.read_excel('Detroit//Detrooit_Mortage_Data.xlsx', sheetname = 'Sheet1')
Let's look at datatypes and if year is in object then we will change into DateTime and set as Index and repeat same for other DataFrame


In [19]:
Mortage_Data.dtypes
Out[19]:
Year                                   object
All_homes                               int64
Single_Family_Residance                 int64
Middle_Tier                             int64
Bottom_tier                             int64
Condominium                             int64
5_bedroom_more                          int64
4_bedroom                               int64
3_bedroom                               int64
2_bedroom                               int64
1_bedroom                               int64
Turnover_AllHomes                     float64
PctOfHomeincreasingValues_AllHomes    float64
PctOfHomeDecreasingValues_AllHomes    float64
MedianValuePerSqrFt_AllHomes            int64
dtype: object
In [20]:
Mortage_Data['Year'] = pd.to_datetime(Mortage_Data['Year'])
In [21]:
Mortage_Data.set_index('Year',inplace=True)
In [41]:
Mortage_Data.head()
Out[41]:
All_homes Single_Family_Residance Middle_Tier Bottom_tier Condominium 5_bedroom_more 4_bedroom 3_bedroom 2_bedroom 1_bedroom Turnover_AllHomes PctOfHomeincreasingValues_AllHomes PctOfHomeDecreasingValues_AllHomes MedianValuePerSqrFt_AllHomes
Year
1999-03-01 59400 136200 59400 46300 69700 109400 72100 62600 50500 51300 0.4805 63.90 32.69 54
1999-04-01 59300 137300 59300 46700 70400 109700 72900 63200 50700 51400 0.4833 64.71 32.94 55
1999-05-01 59400 138200 59400 47000 70400 109600 74200 64200 51700 51800 0.4926 65.76 31.27 55
1999-06-01 60000 138900 60000 47300 70600 111300 75300 64800 52300 52100 0.4722 78.61 18.93 56
1999-07-01 60300 140000 60300 47600 70100 113100 76600 65500 52900 52400 0.4389 86.33 11.82 57
In [42]:
Mortage_Data.tail()
Out[42]:
All_homes Single_Family_Residance Middle_Tier Bottom_tier Condominium 5_bedroom_more 4_bedroom 3_bedroom 2_bedroom 1_bedroom Turnover_AllHomes PctOfHomeincreasingValues_AllHomes PctOfHomeDecreasingValues_AllHomes MedianValuePerSqrFt_AllHomes
Year
2017-02-01 38700 325900 38700 32600 69300 76500 45300 37100 34300 50200 0.5596 92.26 6.25 38
2017-03-01 39600 330900 39600 33100 69600 76900 45900 37700 34700 50800 0.3775 93.75 5.03 39
2017-04-01 40700 334400 40700 33800 70600 78000 46400 38200 35200 51200 0.1802 95.49 3.54 39
2017-05-01 41800 334500 41800 34500 71900 79600 47300 38700 35700 51100 0.1149 95.97 3.15 40
2017-06-01 42600 334100 42600 35100 72900 81000 48700 39400 36300 50800 0.1045 96.13 2.94 41
In [40]:
Mortage_Data.columns.tolist()
Out[40]:
['All_homes',
 'Single_Family_Residance',
 'Middle_Tier',
 'Bottom_tier',
 'Condominium',
 '5_bedroom_more',
 '4_bedroom',
 '3_bedroom',
 '2_bedroom',
 '1_bedroom',
 'Turnover_AllHomes',
 'PctOfHomeincreasingValues_AllHomes',
 'PctOfHomeDecreasingValues_AllHomes',
 'MedianValuePerSqrFt_AllHomes']
In [14]:
Mortage_Per_Data = pd.read_excel('Detroit//Detrooit_Mortage_Data.xlsx', sheetname = 'price_to_rent_ratio')
In [15]:
Mortage_Per_Data.dtypes
Out[15]:
Year                                                  object
Price_to_rent_ratio_all_Homes                        float64
PctofListing_PriceReduction_singleFamilyResidance    float64
PctofListing_PriceReduction_Condominum               float64
PctofListing_PriceReduction_AllHomes                 float64
Per_sqr_fit_AllHomes                                 float64
MedianSoldPrice_AllHomes                             float64
MedianPctOfPriceReduction_SingleFamilyResidance      float64
Median_Price_Cut_Dollar_AllHomes                     float64
PriceCut_SeasAdj_AllHomes                            float64
dtype: object
In [16]:
Mortage_Per_Data['Year'] = pd.to_datetime(Mortage_Per_Data['Year'])
In [17]:
Mortage_Per_Data.set_index('Year',inplace=True)
In [18]:
Mortage_Per_Data.head()
Out[18]:
Price_to_rent_ratio_all_Homes PctofListing_PriceReduction_singleFamilyResidance PctofListing_PriceReduction_Condominum PctofListing_PriceReduction_AllHomes Per_sqr_fit_AllHomes MedianSoldPrice_AllHomes MedianPctOfPriceReduction_SingleFamilyResidance Median_Price_Cut_Dollar_AllHomes PriceCut_SeasAdj_AllHomes
Year
2010-11-01 4.17 7.666667 5.202312 7.585815 0.816 19300.0 16.877938 4000.0 8.228547
2010-12-01 4.23 9.973333 6.896552 9.881014 0.816 16960.0 12.500000 1860.0 10.529425
2011-01-01 4.37 10.046148 4.419890 9.871023 0.808 18290.0 14.326648 2000.0 9.218498
2011-02-01 4.32 10.535943 7.909605 10.453579 0.800 19550.0 13.636364 1440.0 11.036967
2011-03-01 4.32 9.838370 7.428571 9.766491 0.792 18000.0 15.789474 1910.0 8.943306
In [24]:
Mortage_Per_Data.count()
Out[24]:
Price_to_rent_ratio_all_Homes                        80
PctofListing_PriceReduction_singleFamilyResidance    80
PctofListing_PriceReduction_Condominum               80
PctofListing_PriceReduction_AllHomes                 80
Per_sqr_fit_AllHomes                                 80
MedianSoldPrice_AllHomes                             67
MedianPctOfPriceReduction_SingleFamilyResidance      80
Median_Price_Cut_Dollar_AllHomes                     80
PriceCut_SeasAdj_AllHomes                            80
dtype: int64
In [43]:
Mortage_Per_Data.columns.tolist()
Out[43]:
['Price_to_rent_ratio_all_Homes',
 'PctofListing_PriceReduction_singleFamilyResidance',
 'PctofListing_PriceReduction_Condominum',
 'PctofListing_PriceReduction_AllHomes',
 'Per_sqr_fit_AllHomes',
 'MedianSoldPrice_AllHomes',
 'MedianPctOfPriceReduction_SingleFamilyResidance',
 'Median_Price_Cut_Dollar_AllHomes',
 'PriceCut_SeasAdj_AllHomes']
In [33]:
Home_price_index_year = pd.read_excel('Detroit//Home_price_index_yearwise.xlsx')
In [35]:
Home_price_index_year.head()
Out[35]:
Year DetroitHomePriceIndex_PctChangefromPrevious Year USHomePriceIndex_PctChangefromPrevious Year
0 1992 0.032 -0.007
1 1993 0.034 -0.017
2 1994 0.053 0.007
3 1995 0.076 0.002
4 1996 0.076 0.009
In [37]:
Home_price_index_year.set_index('Year', inplace=True)
Lets visualize the home price index Detroit VS USA and observe the change


In [38]:
Home_price_index_year.plot(figsize=(16,6))
Out[38]:
<matplotlib.axes._subplots.AxesSubplot at 0x1f4b4f6ea20>



Detroit Home Index Price is recently increased after year 2015 This article is proof for that.

Lets Explore more about price changes with resepect time in All Home, Single Family Residance and all other remaining categories.

In [61]:
Mortage_Per_Data.head()
Out[61]:
Price_to_rent_ratio_all_Homes PctofListing_PriceReduction_singleFamilyResidance PctofListing_PriceReduction_Condominum PctofListing_PriceReduction_AllHomes Per_sqr_fit_AllHomes MedianSoldPrice_AllHomes MedianPctOfPriceReduction_SingleFamilyResidance Median_Price_Cut_Dollar_AllHomes PriceCut_SeasAdj_AllHomes
Year
2010-11-01 4.17 7.666667 5.202312 7.585815 0.816 19300.0 16.877938 4000.0 8.228547
2010-12-01 4.23 9.973333 6.896552 9.881014 0.816 16960.0 12.500000 1860.0 10.529425
2011-01-01 4.37 10.046148 4.419890 9.871023 0.808 18290.0 14.326648 2000.0 9.218498
2011-02-01 4.32 10.535943 7.909605 10.453579 0.800 19550.0 13.636364 1440.0 11.036967
2011-03-01 4.32 9.838370 7.428571 9.766491 0.792 18000.0 15.789474 1910.0 8.943306
In [74]:
All_homes =  Mortage_Data['All_homes']
Single_Family_Residance = Mortage_Data['Single_Family_Residance']
In [71]:
plt.figure(figsize=(16,6))
plt.plot(All_homes)
plt.ylabel('Price')
plt.xlabel('Year')
plt.title('Price Change in All Homes')
plt.legend()
plt.show()



This clearly shows that the all home prices were reduced after economic clash 2007-2008. Now, it is started increasing and lets zoom from after 2016



In [75]:
homes_df =  Mortage_Data.All_homes.ix['2016-01-01':'2017-06-01']
In [78]:
plt.figure(figsize=(16,6))
plt.plot(homes_df)
plt.ylabel('Price')
plt.xlabel('Month')
plt.title('Price Change in All Homes')
plt.legend()
plt.show()

Lets check for Single Family Residence pricing

In [84]:
plt.figure(figsize=(16,6))
plt.plot(Single_Family_Residance)
plt.ylabel('Price')
plt.xlabel('Month')
plt.title('Price Change in Single_Family_Residance')
plt.legend()
plt.show()



After Aug 2016 price started to increase steadily from 36000 to 42600. According to post, anticipation new govermental change, the average interest change in 30-year, 15-year mortgage and refinancing.

Lets combine, All Homes VS Single Family Residance

In [65]:
#plot
plt.figure(figsize=(16,6))
plt.plot(All_homes)
plt.plot(Single_Family_Residance)
plt.ylabel('Price')
plt.xlabel('Year')
plt.title('Price Change in All Homes,Single_Family_Residance')
plt.legend()
plt.show()
Lets explore about Tiers and Condominium


In [68]:
Middle_Tier = Mortage_Data['Middle_Tier']
Bottom_tier = Mortage_Data['Bottom_tier']
Condominium = Mortage_Data['Condominium']
In [69]:
plt.figure(figsize=(16,6))
plt.plot(Middle_Tier)
plt.plot(Bottom_tier)
plt.plot(Condominium)
plt.ylabel('Price')
plt.xlabel('Year')
plt.title('Price Change in Middle_Tier, Bottom_tier, Condominium')
plt.legend()
plt.show()



Lets check about price changes with respect to bedrooom size


In [80]:
Mortage_Data.head()
Out[80]:
All_homes Single_Family_Residance Middle_Tier Bottom_tier Condominium 5_bedroom_more 4_bedroom 3_bedroom 2_bedroom 1_bedroom Turnover_AllHomes PctOfHomeincreasingValues_AllHomes PctOfHomeDecreasingValues_AllHomes MedianValuePerSqrFt_AllHomes
Year
1999-03-01 59400 136200 59400 46300 69700 109400 72100 62600 50500 51300 0.4805 63.90 32.69 54
1999-04-01 59300 137300 59300 46700 70400 109700 72900 63200 50700 51400 0.4833 64.71 32.94 55
1999-05-01 59400 138200 59400 47000 70400 109600 74200 64200 51700 51800 0.4926 65.76 31.27 55
1999-06-01 60000 138900 60000 47300 70600 111300 75300 64800 52300 52100 0.4722 78.61 18.93 56
1999-07-01 60300 140000 60300 47600 70100 113100 76600 65500 52900 52400 0.4389 86.33 11.82 57
In [81]:
bedroom_five = Mortage_Data['5_bedroom_more']
bedroom_four = Mortage_Data['4_bedroom']
bedroom_three = Mortage_Data['3_bedroom']
bedroom_two = Mortage_Data['2_bedroom']
bedroom_one = Mortage_Data['1_bedroom']
In [82]:
plt.figure(figsize=(16,6))
plt.plot(bedroom_five)
plt.plot(bedroom_four)
plt.plot(bedroom_three)
plt.plot(bedroom_two)
plt.plot(bedroom_one)
plt.ylabel('Price')
plt.xlabel('Year')
plt.title('Price Change in Bedroom Size')
plt.legend()
plt.show()


Interesting! All graphs shows same pattern of in pricing. Further, I will be analyzing relation in PriceReduction