Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python to analyze the real estate market

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use Python for data analysis of the real estate market". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it slowly to study and learn "how to use Python for data analysis of the real estate market" together.

Access to land data

Land market data will generally be published in the local public resource trading center, but often only the week or month data will be published, so we can go to professional land websites to obtain transaction data.

This article takes the earth flow net as an example, this website structure is simple, simple url page structure, and then use xpath to parse the data. Due to space limitation, crawler code is not repeated, only core code is provided.

def main(): for page in range(1,46): #Set 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 page" + str(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('获取完成') breakif __name__ == '__main__': time.sleep(random.uniform(1,2)) main() 运行爬虫代码,提取到广州1238块土地数据。以下为简单清洗后部分数据:

Analyzing Land Data

Land transaction status

Land Bidding, Auction and Listing in Guangzhou in Recent 10 Years

From 2011 to 2016, Guangzhou City has less land for bidding, auction and hanging transactions, and the planned building area for transactions in 2016 is only 773,000 ㎡. After 2017, the transaction scale began to enter a climax, and the planned construction area of the transaction in 2018 reached 16.355 million ㎡.

Since 2019, Guangzhou land bidding and auction transaction area (ten thousand ㎡)

In the past 10 years, Guangzhou's land transactions are mainly industrial land, other land and residential land, with industrial land accounting for 41.19%, which is also an important driving force for the development of Guangzhou's industrial enterprises.

land transaction area

Land bidding, auction and hanging transaction area in each district of Guangzhou in recent 10 years (ten thousand ㎡)

From the clinch a deal area to see, Nansha District and Panyu District each year have a certain land clinch a deal, Yuexiu District and Tianhe District clinch a deal less land. Since 2020, the land market in Nansha District has been hot, and the transaction area is much higher than that in other areas of Guangzhou.

Guangzhou Real Estate Market Analysis

The analysis of real estate market mainly includes new house and second-hand house transaction market. Because the number of second-hand houses on the general real estate information release platform is much larger than that of new houses, in order to obtain larger sample data as much as possible and improve the accuracy of analysis, this paper analyzes the real estate market with the transaction data of second-hand houses in Guangzhou.

Get data on second-hand housing

This article through Python to obtain the Guangzhou second-hand housing transaction data published by Fangtianxia. The crawler in the house is also relatively simple. The crawler logic is similar to that of shells looking for houses. The only thing to pay attention to is the processing of jumping to the next sub-area after traversing a sub-area. The core code is given below:

def main(): #Zengcheng a080; Panyu a078; Nansha a084; Huadu a0639; Baiyun a076; Haizhu a074; Yuexiu a072; Liwan a071; Tianhe a073; Conghua a079; Huangpu a075 district_list = ['a084',' a078','a080',' a0639','a076',' a074','a072',' a071','a073',' a079','a075']#district for district in district_list: for page in range(1,101): #Set 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 +'th' + 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: #遍历完子地区后跳转 print('获取完成') breakif __name__ == '__main__': time.sleep(random.uniform(1,2)) main() 代码运行几分钟就提取下22170套广州二手房数据,简单清洗后部分数据展示如下:

Analyze the data of second-hand housing

Volume price trend

Price Trend of Second-hand Housing in Guangzhou in Recent 5 Years

From January to June 2020, the average price of second-hand houses in Guangzhou is basically the same as that in 2019. From the turnover to see, February affected by the epidemic only clinch a deal of 70 sets of second-hand houses, since March, the epidemic situation has gradually been controlled, the real estate market is good, June clinch a deal of 1337 sets of second-hand houses.

Distribution of house prices

Average price of second-hand houses in each district of Guangzhou in the first half of 2020 (Yuan/㎡)

According to the transaction of real estate, from January to June 2020, the building with the largest number of transactions of second-hand houses in Guangzhou is Jinxiu Tianlun Garden located in Zengcheng District, with 78 sets of transactions in total, and the average transaction price is 18565.40 yuan/㎡.

correlation analysis

import pandas as pdimport matplotlib.pyplot as pltimport matplotlib as mplimport seaborn as sns%matplotlib inlinesns.set_style('white') #Set graphic background style to white df = pd.read_excel ("D:\data\real estate data analysis\Guangzhou second-hand housing.xlsx")df = df["'Room ',' Hall','Area (㎡)','Floors',' Transaction Unit Price (Yuan/㎡)']] #Select the desired column df.rename (columns={'room':' room','hall':' hall','area (㎡)': 'area',' floor':'floor',' transaction unit price (yuan/㎡)':'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]) Thank you for reading. The above is the content of "How to use Python to analyze the real estate market". After studying this article, I believe everyone has a deeper understanding of how to use Python to analyze the real estate market. The specific use situation also needs everyone to practice verification. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report