程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Analyzing Guangzhou real estate market with Python

編輯:Python

Hello everyone , I'm Charlie . It's been a while since I wrote more , I would like to apologize to my friends who have followed me . This time I want to combine the real estate business , For the city of Guangzhou , Application Python To do data analysis , In order to provide you with some analytical ideas . Why should we analyze the real estate market ? The real estate industry has distinct regional characteristics , From the perspective of real estate enterprises , The choice of city determines the success or failure of investment to a certain extent . therefore , It is very important to study and judge the market of a city . A few years ago , The same funds are allocated to Nanjing and Changsha , The difference in return on investment is huge .2017 - 2019 Second hand houses in Nanjing and Changsha ( element /㎡)

that , How should we analyze the real estate market ? From the perspective of data analysis , Summarized and combed the train of thought , I think a city's real estate market analysis should include the urban economy 、 related policy 、 Land market and real estate market Four aspects . Urban economy reflects the economic strength and potential of a city , The following indicators can be subdivided : Per capita GDP And unit area GDP、 Per capita fiscal revenue and fiscal revenue per unit area 、 The size of high net worth people 、 The net inflow of population 、 Proportion of tertiary industry 、 Industrial complementarity 、 Real estate investment dependency 、 City friendliness, etc . The policies formulated by the government also have a great impact on the real estate market , The policies with high relevance are Financial policy 、 population policy 、 Land policy and house purchase policy etc. . Finally, the city Land market and real estate market analysis , This is also the whole analysis At the core Part of .

The real estate market analysis framework follows , I will combine Python, Take Guangzhou for example , Try to analyze the Land market and real estate market , The analysis of the urban economy and related policies will be described in future articles .

Analysis of Guangzhou land market


Land market includes primary market and secondary market , The primary market is The market of land use right transfer , That is, the market where the state, through its designated government departments, expropriates urban state-owned land or rural collective land as state-owned land and transfers it to users , Land transferred , It can be a raw land , It can also be developed to “ Seven connections and one leveling ” Mature land . The secondary market is Re transaction after land use right transfer , Land users will meet the requirements 、 Land use rights that can be traded , Enter the market for trading in the circulation field . Limited to space , This paper only analyzes the data from the primary land market .

Obtain land data

Land market data will generally be publicized in local Public resource trading center , But it is often the case that only the data of the current week or the current month will be published , therefore , We can go to a professional land website to get transaction data . This paper takes the earth flow net as an example , The structure of this website is simple , ordinary url Flip structure , And then use xpath Just parse the data . Limited to space , The crawler code will not be repeated , Only core code is provided .

def main():
for page in range(1,46): # Set the number of pages here
url = 'https://www.tudinet.com/market-213-0-0-0/list-o1ctime-pg{}.html'.format(page)
print(url)
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36',
}
response = requests.request("GET", url, headers = headers)
#print(response.status_code)
if response.status_code == 200:
re = response.content.decode('utf-8')
print(" Extracting No " + str(page) + " page ")
time.sleep(random.uniform(1,2))
print("-" * 80)
# print(re)
parse = etree.HTML(re) # Parse web pages
items = parse.xpath('.//div[@class="land-l-cont"]/dl')
parse_page(items)
if len(items) < 10:
print(' Get done ')
break
if __name__ == '__main__':
time.sleep(random.uniform(1,2))
main()

Run the crawler code , Extracted to Guangzhou 1238 block Land data . Here are some data after simple cleaning :

Analyze land data

Land transaction status

near 10 Guangzhou land bidding, auction and listing transactions in

2011 - 2020 year , Half of the land in Guangzhou has not been sold through bidding, auction and auction, and the scale of the land in the current auction accounts for , The proportion of land traded is only 49.71%, The overall turnover rate is not high . The reasons for not closing the deal are mainly concentrated in the fact that there is no intended bidder 、 The bid fails to reach the specified reserve price, etc .

Land transaction area

near 10 Guangzhou land auction and listing transaction area in ( ten thousand ㎡)

2011 - 2016 In, there were few land auctions in Guangzhou ,2016 The planned building area for annual transaction is only 77.30 ten thousand ㎡.2017 After, the transaction scale began to reach a climax ,2018 The planned building area of the annual transaction reached 1635.50 ten thousand ㎡.2019 The transaction area of land bidding, auction and listing in Guangzhou since ( ten thousand ㎡)

Judging from the land transaction in each month , Guangzhou 2019 In the first half of the year, the local auction market was relatively quiet , It began to return to normal after the middle of the year ,2019 Every year, the subsoil auction market is in a hot state .2019 year 11 The month and 12 The parcels of land were traded in January 21 Block and 38 block .

Land transaction structure

near 10 In, the proportion of land types traded through land bidding, auction and listing in Guangzhou (%)

near 10 In recent years, the land traded in Guangzhou is mainly industrial land 、 Other land and residential land are mainly used , Industrial land accounts for as much as 41.19%, This is also an important reason for the development of industrial enterprises in Guangzhou .

Land transaction area

near 10 In, the transaction area of land bidding, auction and listing in various districts of Guangzhou ( ten thousand ㎡)

From the transaction area , Nansha District and Panyu District have certain land transactions every year , Yuexiu District and Tianhe District have a small number of land transactions .2020 Since then , Nansha District land market is hot , The transaction area is much higher than that of other areas in Guangzhou .

Guangzhou real estate market analysis


The real estate market analysis mainly includes New and second-hand housing market , As the general real estate information release platform, the number of second-hand houses is much larger than that of new houses , In order to obtain larger sample data as much as possible , Improve the accuracy of analysis , This paper analyzes the real estate market based on the transaction data of second-hand houses in Guangzhou .

Get second-hand housing data

This passage Python Obtain the transaction data of second-hand houses in Guangzhou published by fangtianxia . The reptiles in fangtianxia are also relatively simple , The reptile logic is similar to that of a shell looking for a house , The only thing to note is that after traversing a sub region, it jumps to the next sub region . Here is the core code :

def main():
# Zengcheng a080; Panyu a078; Nansha a084; Huadu a0639; White clouds a076; Haizhu a074; Yuexiu a072; Liwan a071; Tianhe River a073; Conghua a079; Whampoa a075
district_list = ['a084', 'a078','a080', 'a0639','a076', 'a074','a072', 'a071','a073', 'a079','a075'] # region
for district in district_list:
for page in range(1,101): # Set the number of pages here
url = 'https://gz.esf.fang.com/chengjiao-{0}/i3{1}/'.format(district, page)
print(url)
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36',
}
response = requests.request("GET", url, headers = headers)
if response.status_code == 200:
re = response.content.decode('utf-8')
print(" Extracting " + district +' The first ' + str(page) + " page ")
time.sleep(random.uniform(1,2))
print("-" * 80)
# print(re)
parse = etree.HTML(re) # Parse web pages
items = parse.xpath('.//div[@name="div_houselist"]/dl')
parse_page(items)
if len(items) < 30: # After traversing the sub region, jump to
print(' Get done ')
break
if __name__ == '__main__':
time.sleep(random.uniform(1,2))
main()

The code runs for a few minutes to extract 22170 set Guangzhou second-hand housing data , Some data after simple cleaning are shown as follows :

Analyze second-hand housing data

Volume and price trends

near 5 The volume and price trend of second-hand houses in Guangzhou in

From the quantity and price trend of second-hand houses in Guangzhou in recent years , since 2015 House prices have been rising since ,2018 The average price of second-hand houses reached 35000 element /㎡.2019 In, the house price fell back , However, the number of second-hand houses has reached the peak in recent years , All year round 8940 set .2020 year 1 Month to 6 The volume and price trend of second-hand houses in Guangzhou

2020 year 1 Month to 6 month , The average price of second-hand houses in Guangzhou is the same as 2019 Basically the same year . In terms of volume ,2 Affected by the epidemic, only transactions were made in January 70 A second-hand house ,3 Since the month , The epidemic has been brought under control , The real estate market is improving ,6 The second-hand house was sold in January 1337 set .

House price distribution

2020 The average price of second-hand houses in Guangzhou in the first half of ( element /㎡)

From the distribution of house prices ,2020 year 1 Month to 6 Yuexiu District and Tianhe District have the highest average price of second-hand houses in January , The average price is 46767.52 element /㎡ and 46433.89 element /㎡. Conghua district has the lowest house price , Only for 12190.67 element /㎡.

Real estate transaction TOP20

2020 year 1 Month to 6 The second-hand houses in Guangzhou were sold in June TOP20 properties for sale

Judging from the real estate transaction ,2020 year 1 Month to 6 In June, the largest number of second-hand houses in Guangzhou was Jinxiu Tianlun garden in Zengcheng district , A total deal 78 set , The average transaction price is 18565.40 element /㎡.

correlation analysis

import pandas as pdimport matplotlib.pyplot as pltimport matplotlib as mplimport seaborn as sns%matplotlib inlinesns.set_style('white') # Set the graphic background style to white df = pd.read_excel("D:\data\ Real estate data analysis \ Second hand houses in Guangzhou .xlsx")df = df[[' room ',' hall ',' area (㎡)',' The layer number ',' Unit price ( element /㎡)']] # Select the columns you want df.rename(columns={' room ': 'room', ' hall ': 'hall', ' area (㎡)': 'area', ' The layer number ': 'floor', ' Unit price ( element /㎡)': 'price'}, inplace=True)fig,axes=plt.subplots(1,2,figsize=(12,5))sns.regplot(x= 'room',y='price',data=df,color='r',marker='+',ax=axes[0])sns.regplot(x='hall',y='price',data=df,color='g',marker='*',ax=axes[1])

near 5 Guangzhou second-hand room in 、 area 、 The relationship between floor and house price

By drawing the regression map of second-hand houses in Guangzhou , We found that , Number of second-hand rooms in Guangzhou 、 There is little correlation between area and house price . There seems to be a strong positive correlation between house floors and house prices , In fact, it is affected by three outliers , Not relevant .

Guangzhou real estate market section


From the perspective of Guangzhou land market , The land market has warmed up in recent years , In particular, the land market transactions in Nansha District and Panyu District are stable , There is still development potential in the future . From the perspective of the real estate market , Second hand house in Guangzhou 2019 The price has not changed much over the years , maintain 30000 element /㎡ about . The second-hand housing transaction was frustrated under the epidemic , Some real estate enterprises try to exchange price for quantity to strive for a greater amount of dematerialization . After the epidemic situation was gradually brought under control , Second hand housing transactions have recovered significantly . House prices in the city center remain high , Conghua and Zengcheng in the north of Guangzhou have lower house prices , There is still room for improvement .

Statement

--

1. This data analysis is only for the purpose of learning and research , The conclusions provided are for reference only ;

2. The author knows little about the real estate industry , The relevant description may be incomplete , Please don't take your seat .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved