Analysis of Guangzhou real estate market with Python

Hello, I'm Charlie. I haven't been more polite for a while. I apologize to my friends who pay attention to me. This time, I want to use Python to analyze the data for Guangzhou in combination with the real estate business, in order to provide you with some analysis ideas. Why analyze the real estate market? The real estate industry has distinct regional characteristics. From the perspective of real estate enterprises, the choice of cities 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. As early as a few years ago, when the same funds were allocated to Nanjing and Changsha, the difference in return on investment was huge. Second hand houses in Nanjing and Changsha from 2017 to 2019 (yuan / m2)

So, how should we analyze the real estate market? From the perspective of data analysis, I summarized and combed my ideas. I think the analysis of a city's real estate market should include four aspects: urban economy, relevant policies, land market and real estate market. Urban economy reflects the economic strength and potential of a city, which can be subdivided into the following indicators: per capita GDP and GDP per unit area, per capita fiscal revenue and fiscal revenue per unit area, scale of high net worth population, net population inflow, proportion of tertiary industry, industrial complementarity, dependence on real estate investment, city friendliness, etc. The policies formulated by the government also have a great impact on the real estate market. The policies with high relevance include financial policy, population policy, land policy and house purchase policy. The last is the analysis of urban land market and real estate market, which is also the core of the whole analysis.

Next, I will try to analyze Guangzhou's land market and real estate market in combination with Python and take Guangzhou as an example. The analysis of urban economy and relevant policies will be described in future articles.

Guangzhou land market analysis

The land market includes the primary market and the secondary market. The primary market is the market for the transfer of land use rights, that is, the market in which the state, through its designated government departments, transfers urban state-owned land or rural collective land to users after expropriation as state-owned land. The transferred land can be raw land or mature land that has been developed to achieve "seven supplies and one leveling". The secondary market is the re transaction after the transfer of land use right. The land user will reach the specified and tradable land use right and enter the market for transaction in the circulation field. Limited by space, this paper only analyzes the data from the primary land market.

Obtaining land data

Land market data are generally publicized in the local public resources trading center, but often only the data of the current week or current month are publicized. Therefore, we can go to a professional land website to obtain transaction data. This paper takes tuliu.com as an example. This website has a simple structure, a simple url page turning structure, and then parses the data with xpath. Limited to space, the crawler code will not be repeated, but only the core code.

def main():
    for page in range(1,46):   #The number of pages is set 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) + "page")
            time.sleep(random.uniform(1,2))
            print("-" * 80)
            # print(re)
            parse = etree.HTML(re)  #Parsing web pages
            items = parse.xpath('.//div[@class="land-l-cont"]/dl')
            parse_page(items)
            if len(items) < 10:  
                print('Get complete')
                break

if __name__ == '__main__':
    time.sleep(random.uniform(1,2))
    main()

Run the crawler code to extract 1238 pieces of land data in Guangzhou. The following are some data after simple cleaning:

Analysis of land data

Land transaction status

Land bidding, auction and listing transactions in Guangzhou in recent 10 years

From 2011 to 2020, half of the land in Guangzhou was not traded in land bidding, auction and auction, and the proportion of land traded was only 49.71%, and the overall transaction rate was not high. The reasons for not closing the deal are mainly that there is no intended bidder, the bid does not reach the specified reserve price, etc.

Land transaction area

Land bidding, auction and listing transaction area in Guangzhou in recent 10 years (10000 m2)

From 2011 to 2016, there were few land transactions in land bidding, auction and listing in Guangzhou, and the planned construction area in 2016 was only 773000 m2. After 2017, the transaction scale began to reach a climax, and the planned construction area reached 16.355 million m2 in 2018. Transaction area of land bidding, auction and listing in Guangzhou since 2019 (10000 m2)

From the perspective of land transactions in each month, the local auction market in Guangzhou was relatively quiet in the first half of 2019, began to return to normal after the middle of the year, and entered a hot state at the end of 2019. In November and December 2019, 21 and 38 parcels of land were sold respectively.

Land transaction structure

Proportion of land types traded by land bidding, auction and listing in Guangzhou in recent 10 years (%)

In recent 10 years, the land traded in Guangzhou is mainly industrial land, other land and residential land, and the proportion of industrial land is as high as 41.19%, which is also an important reason for the development of industrial enterprises in Guangzhou.

Land transaction area

Land bidding, auction and listing transaction area in various districts of Guangzhou in recent 10 years (10000 m2)

From the perspective of transaction area, Nansha District and Panyu District have certain land transactions every year, and Yuexiu District and Tianhe District have less land transactions. Since 2020, the land market in Nansha District has been hot, and the transaction area is much higher than that in other parts of Guangzhou.

Analysis of Guangzhou real estate market

The real estate market analysis mainly includes the 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 the analysis, this paper analyzes the real estate market with the transaction data of second-hand houses in Guangzhou.

Obtain second-hand housing data

This paper obtains the transaction data of second-hand houses in Guangzhou published by fangtianxia through Python. The reptile in fangtianxia is also relatively simple. The reptile logic is similar to that of looking for a house in a shell. The only thing to pay attention to is to jump 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']  #region
    for district in district_list:
        for page in range(1,101):   #The number of pages is set 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)  # Parsing web pages
                items = parse.xpath('.//div[@name="div_houselist"]/dl')
                parse_page(items)
                if len(items) < 30:  #Jump after traversing the sub region
                    print('Get complete')
                    break

if __name__ == '__main__':
    time.sleep(random.uniform(1,2))
    main()

After running the code for a few minutes, the data of 22170 second-hand houses in Guangzhou are extracted. After simple cleaning, some data are shown as follows:

Analyze second-hand housing data

Volume price trend

Volume and price trend of second-hand houses in Guangzhou in recent 5 years

From the volume and price trend of second-hand houses in Guangzhou in recent years, house prices have been rising since 2015, and the average price of second-hand houses reached 35000 yuan / m2 in 2018. House prices fell in 2019, but the number of second-hand houses sold reached the peak in recent years, with 8940 units sold in the whole year. Volume and price trend of second-hand houses in Guangzhou from January to June 2020

From January to June 2020, the average price of second-hand houses in Guangzhou was basically the same as that in 2019. In terms of trading volume, only 70 second-hand houses were sold in February affected by the epidemic. Since March, the epidemic has been gradually controlled, and the real estate market has improved. 1337 second-hand houses were sold in June.

House price distribution

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

From the distribution of house prices, Yuexiu District and Tianhe District have the highest average price of second-hand houses from January to June 2020, with average prices of 46767.52 yuan / m2 and 46433.89 yuan / m2 respectively. Conghua district has the lowest house price, only 12190.67 yuan / m2.

Top 20 real estate transactions

From January to June 2020, the top 20 second-hand housing transactions in Guangzhou

From the perspective of real estate transactions, the largest number of second-hand houses in Guangzhou from January to June 2020 was Jinxiu Tianlun garden in Zengcheng District, with a total of 78 sets of transactions, with an average transaction price of 18565.40 yuan / m2.

correlation analysis

import pandas as pdimport matplotlib.pyplot as pltimport matplotlib as mplimport seaborn as sns%matplotlib inlinesns.set_style('white')   #Set the drawing background style to white df = pd.read_excel("D:\data\Real estate data analysis\Second hand house in Guangzhou.xlsx")df = df[['room','office','the measure of area(㎡)','Number of layers','Transaction unit price(element/㎡)']] #Select the desired column DF Rename (columns = {room ':'room','hall ':'area','number of floors':'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])

The relationship between the living room, area, floor and house price of second-hand houses in Guangzhou in recent 5 years

By drawing the regression map of second-hand houses in Guangzhou, we find that the number and area of second-hand houses in Guangzhou have little correlation with house prices. It seems that there is a strong positive correlation between House floor and house price. In fact, it is affected by three outliers and has no correlation.

Guangzhou real estate market

From the perspective of Guangzhou land market, the land market has warmed up in recent years, especially in Nansha District and Panyu District. The land market transactions are stable and still have development potential in the future. From the perspective of the real estate market, the price of second-hand houses in Guangzhou has changed little since 2019, maintaining about 30000 yuan / m2. Under the epidemic, second-hand housing transactions were frustrated, and some real estate enterprises tried to exchange price for quantity to strive for greater de conversion. After the epidemic was gradually brought under control, second-hand housing transactions recovered significantly. House prices in the city center remain high. Conghua and Zengcheng, north of Guangzhou, have low house prices and still have room for rise.

statement

1. This data analysis is only for learning and research purposes, and the conclusions provided are only for reference;
2. The author knows little about the real estate industry, and the relevant description may be imperfect. Please do not take your seat according to the number.

Keywords: Python Back-end

Added by venom999 on Mon, 10 Jan 2022 10:02:13 +0200