-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRealEstateAnalyze.py
More file actions
54 lines (36 loc) · 1.91 KB
/
RealEstateAnalyze.py
File metadata and controls
54 lines (36 loc) · 1.91 KB
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
47
48
49
50
51
from GetData.dataqueryanalyze import RedfinDataRetrieve, DataframeLoad
import pandas as pd
import numpy as np
#redfin = RedfinDataRetrieve()
#Use the three below methods to update the redfin and zillow data -- don't query too often
#redfin.Get_Redfin_Data() #gets individual housing data
#redfin.Get_Zillow_Data() #get market pricing data
#redfin.Get_ZillowRent_Data() #gets market rental data
#The DataframeLoad class is utilized to return dataframes based upon the data imported from the RedfinDataRetrieve class
pandasquery = DataframeLoad()
ZillowDF = pandasquery.GetZillowDF()
ZillowRentDF = pandasquery.GetZillowRentDF()
RedfinDF = pandasquery.GetRedfinDF()
#inputs
mortgageRate = .045
propertyTaxRate = .0125
#Adds an average price field -- to do a weighted ranking consider price and rent differential
avgPriceMergeDF = pd.merge(RedfinDF, ZillowDF, left_on='ZIP OR POSTAL CODE', right_on='RegionName')
print(avgPriceMergeDF)
#Adds an average rent column and other calculated fields
avgRentMergeDF = pd.merge(RedfinDF, ZillowRentDF, left_on='ZipBedKey', right_on='ZipBedKey', how='left')
print(avgRentMergeDF)
avgRentMergeDF['PRICE'] = avgRentMergeDF['PRICE'].astype(float)
avgRentMergeDF['2019-09'] = avgRentMergeDF['2019-09'].astype(float)
#Monthly rental cost assumptions
mortgageEstimate = np.pmt(mortgageRate,12*30,avgRentMergeDF['PRICE'])/12*-1
propertyTaxEstimate = (avgRentMergeDF['PRICE']*propertyTaxRate)/12
insruanceEstimate = 150
HOACost = 200
depreciationCost = (avgRentMergeDF['PRICE']*.01)/12
monthlyCostEstimate = mortgageEstimate + propertyTaxEstimate + insruanceEstimate + HOACost + depreciationCost
#Adds a monthly cost estimate field
avgRentMergeDF['monthlyCostEstimate'] = monthlyCostEstimate
avgRentMergeDF['AvgRentVariance'] = avgRentMergeDF['2019-09'] - monthlyCostEstimate
#Print the DF to a csv
avgRentMergeDF.to_csv("C:/Users/YOURNAME/PandasDFProjects/RedfinData/CSVDownload/Redfin_ZillowMerge.csv")