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 population data

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "how to use Python to analyze population data". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I. Analysis of objectives

Since the founding of New China 70, it has experienced a lot of ups and downs, and there have been many changes in policy, economy, culture and population.

Population change has a huge and far-reaching impact on social and economic development, so today we analyze China's population change from many angles:

Total population

Male to female ratio

Urbanization

growth rate

Population structure

Second, crawling data

Data sources for China's population can be obtained from the "National data" website. This is a website provided by the National Bureau of Statistics, which contains data and information from many countries.

1. Request single page data

In the national data website, there are population-related data from the founding of New China to 2018.

Among the population data, there are three items that we need: the total population, the growth rate, and the population structure.

Let's press F12 to see the requested link, and then copy the link to request data using requests.

Using only a simple get request, the data is obtained, and the json data is returned directly!

two。 Paging data

Our purpose this time is to capture all the population data since the people's Republic of China, and the page can get nearly 20 years of data at most, so we need to analyze the paging parameters in the web request.

Analyzing the request parameters, Pig found that there are two main parameters: zb and sj, which represent the index and time respectively.

Parameter: sj=LAST10, which means nearly 10 years, so Brother Pig wondered: can sj=LAST70 get 70 years of data?

Then we change the zb parameters to get all the data!

3. Save Excel

After getting the data, we first clean the data, extract the data we need, and then organize and save it to Excel. We still use Master Pan (pandas) in data processing.

Let's take a look at the saved excel file data.

4.2019 data

The only incompleteness of the current data is that there is no 2019 data, because 2019 has just finished, so the data has not yet been registered on the website, we can only figure it out and fill it up.

Brother Pig obtained the relevant data for 2019 according to the population data in the 2019 national economic report released by the National Bureau of Statistics on January 17, 2020.

Let's take a look at the complete 70-year population data.

III. Data analysis

After the data is saved, we can start the data analysis step. Generally, before we analyze the data, we need to have a train of thought: what to analyze? From what point of view? What kind of visual graphics do you choose? What conclusion has been drawn? (of course, the analysis report in actual work needs to be more rigorous, but the general thinking is similar.)

1. Total population

First of all, we extract the data from the column "year-end total population" in Excel for analysis.

Directly on the code, Brother Pig first uses Master Pan to read Excel, and then gets the column data of the total population (please see the source code for the complete code).

The above code is a little different from the previous curve drawing: add a custom curve background color and area color function, the next time students want to customize the pyecharts curve background, you can refer to the code here.

Brother Pig marked four points in the following picture:

Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community

1949: new China was founded with a total population of 542 million

1980: family planning officially began, with a total population of 987 million

2016: fully liberalize the second child, with a total population of 1.383 billion

2019: total population 1.4 billion

By observing the graph of the total population, we can see that:

Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community

The population as a whole is increasing, but the growth curve is slowly slowing down. according to the forecast of the Chinese Academy of Social Sciences, China's population will reach a peak of 1.442 billion in 2029, and then decline gradually.

The only decrease in population since the founding of New China (2020) is in 1960 and 1961, which are the years of natural disasters in China.

According to the total population, let's analyze the population growth in the 31 years before and after the implementation of family planning.

According to the above picture, we can see that family planning does control population growth!

The release of the second child has not ushered in the baby boom, and the revised version of the World population Outlook 2017 released by relevant United Nations agencies gives similar expectations. It tends to assume that China's population has begun an inverted V-shaped reversal, reaching a peak of more than 1.3 billion in 2050, and then accelerating the decline (low, medium and high fertility rates, from the United Nations population Fund).

two。 Ratio of male to female population

We often hear people say: "China has an unbalanced male-to-female ratio, and 30 million Chinese men will not be able to get a wife."

In fact, this is the result of the imbalance between men and women in our country.

Below, Brother Pig analyzes the male-to-female ratio in China from the following four angles:

Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community

Ratio of men to women in 2019

Male as a proportion of the total population

Male and female population curve

The difference between the population of men and women

According to the above four figures, we can draw some conclusions:

Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community

Since the founding of the people's Republic of China, the male population has been larger than the female population, which may have something to do with the preference of boys over daughters in our country.

The highest proportion of men was 51.96% at the beginning of the founding of the people's Republic of China, and the lowest was 50.82% in 1996. The following picture shows the male-to-female ratio of China, India, Japan, the United Kingdom and the United States from Kuaiyi data, which clearly shows that the male-to-female ratio between China and India has been out of balance.

3. In 2000, the maximum difference between men and women in China was 41.31 million, and the minimum difference was 17.18 million in 1965.

4. Since 2006, the imbalance of male to female ratio in China has been alleviated year by year.

How many male compatriots in our country will be bachelors? Due to the limited space, we will do a special analysis of this problem in the next issue!

3. Population urbanization

Many students do not understand what "population urbanization" is. Brother Pig quotes Baidu Encyclopedia as follows:

Population urbanization refers to the process of transforming rural population into urban population and agricultural population into non-agricultural population. It is the product of the development of social productive forces to a certain stage.

Urbanization is a comprehensive indicator that can be used to measure local economic development, infrastructure and people's living standards.

At the same time, the process of urbanization is also an important supporting force in the demand level of the real estate market. The following picture shows the relationship between population urbanization and social development.

According to the study of urbanization around the world by American geographer Northam, the urbanization of the world is divided into three stages:

Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community

In the initial stage (population urbanization is less than 30%): the rural population is dominant, the level of industrial and agricultural productivity is low, industry provides few employment opportunities, and the agricultural surplus labor force cannot be released.

In the medium term (30% to 70% of the population urbanization): the industrial base is relatively strong, the economic strength is significantly enhanced, the labor productivity in rural areas has increased, the surplus labor force has shifted to industry, and the proportion of urban population has rapidly exceeded 50%, and then increased to 70%.

In the later stage (70%-90% of population urbanization): the transformation from rural population to urban population tends to stop, the proportion of rural population is stable at about 10%, and the urban population can reach about 90%, reaching saturation. The urbanization in this process is no longer the flow of population from rural areas to cities, but the structural transfer of urban population between industries, mainly from the secondary industry to the tertiary industry.

Let's take a look at the data analysis of population urbanization in China:

From the analysis of the above figure, we can see:

Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community

In 2019, China's population urbanization reached 60.6%, which is in the middle stage of population urbanization.

In 1995, China's rural population reached a peak of 859 million.

The pace of urbanization in China accelerated in 1996, and urbanization exceeded 30% in the same year, entering the middle stage of urbanization.

In 2010, China's urban population is about the same as the rural population is about 670 million, urbanization is 50%.

The United Nations has predicted the process of population urbanization in China: the initial stage of urbanization in China is from 1949 to 1995, the middle stage is from 1996 to 2032, and the later stage is after 2033.

4. Population growth rate

Data visualization code brother pig will not be released, want to see the students directly take a look at the source code, we directly look at the picture.

From the picture above, we can see:

Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community

In the three years of natural disasters (1959, 1960, 1961), China's population mortality rate has increased sharply, the birth rate has also declined, and the population has experienced negative growth for the first time since the founding of the people's Republic of China.

In the two years after the natural disaster (1962, 1963) ushered in the largest wave of fertility in China, we can also verify this conclusion through the data of the fifth census in 2010.

3. After three years of natural disasters, the mortality rate in China has been stable, maintaining at about 6-7 ‰.

4. The birth rate in China as a whole has been declining, and the birth rate was declining even before family planning.

5. In the three years after China fully liberalized its second child in 2017 (2016-2019), the birth rate did not improve, but continued to decline.

At present, women of childbearing age are basically post-85-90s. Affected by family planning (1980), the number of women of childbearing age is less than before, and the number of children is naturally less than before. This situation will continue.

As the birth rate decreases and the death rate increases, population growth slows down. The Chinese Academy of Social Sciences predicts that China's population will decrease slowly after reaching its peak (1.442 billion) around 2029!

Digression: after crawling the data, Brother Pig found that the data provided by the National data website was also wrong: the population in 1961 was lower than that in 1960, but the growth rate was an integer!

5. Age structure

Population age structure is an index to measure aging and demographic dividend.

Aging: refers to the process in which the elderly population increases relatively and accounts for an increasing proportion of the total population. it is generally believed that when the elderly population over 60 accounts for 10% of the total population in a country or region, or the elderly population over 65 accounts for 7% of the total population, it means that the population of this country or region is in an aging society. Baidu encyclopedia

Aging is a stage that every country and every society will go through. at present, the problem of aging in developed countries is more serious than that in developing countries. According to a ranking of aging in all countries in the world provided by Kuaiyi data, China only ranks 65th. The first place is Japan, while the top few are basically European countries.

Demographic dividend: an economic term, refers to a country's working-age population accounts for a large proportion of the total population, the dependency rate is relatively low, creating favorable population conditions for economic development, the whole country's economy shows a situation of high savings, high investment and high growth.

To put it simply, the demographic dividend means that the population of the labor force is larger than that of the non-labor force, and the proportion of the labor force is relatively high, which ensures the demand for labor in the economic growth. The abundant labor resources and cost advantages have made China the world factory and the engine of world economic growth.

From the analysis of the above three pictures, we can get:

In 1982, children aged 0-14 accounted for 33.59%, but in 2019, the proportion decreased to 17.9%, the proportion dropped to nearly half.

In 2019, China's population over the age of 65 accounts for 12.57%, which has entered an aging society. 92 countries in the world are aging, and China ranks 65th.

In 2010, China's total dependency ratio reached the lowest: 34.2%, which means that every three workers need to support one old person or child.

The demographic dividend peaked in 2010 and has been declining since then.

China's elderly population is 176 million in 2019. China's aging is about to enter a rapid aging stage. at present, the pension of many provinces in our country is urgent, and the reform of our pension system is extremely urgent.

That's all for "how to use Python to analyze population data". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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: 238

*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

Development

Wechat

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

12
Report