news 2026/9/27 16:36:55

截至2022年近10年中国人口数据

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
截至2022年近10年中国人口数据


#转置数据框,按索引(年份)升序排列数据框,以便后续计算环比指标
df_total_T=df_total.T
df_total_T=df_total_T.sort_index()
df_total_T


#计算各个指标的年环比指标
cols=df_total_T.columns.to_list()
for col in cols:
col_str=col+"_pct"
df_total_T[col_str]=df_total_T[col].pct_change(periods=1)
df_total_T.head(2)


#年末总人口规模和环比趋势分析。
fig=plt.figure(figsize=(12,6))#设置画布


ax1=fig.add_subplot(2,1,1)
ax1.plot(df_total_T['年末总人口(万人)'])
ax1.axhline(y=140000,color='red')#14亿红线
ax1.set_title('年末总人口(万人)趋势')

ax2=fig.add_subplot(2,1,2)
ax2.plot(df_total_T['年末总人口(万人)_pct'])
ax2.axhline(y=0,color='red')#正负值界限
ax2.set_title('年末总人口(万人)_pct趋势')

plt.tight_layout()
plt.show()


plt.figure(figsize=(12,4))
plt.plot(df_total_T['城镇人口(万人)']/df_total_T['年末总人口(万人)'],marker='+')
plt.axhline(y=0.5,color='red')
plt.title('城镇人口占比')
plt.show()


plt.figure(figsize=(12,4))
plt.plot(df_total_T['男性人口(万人)']/df_total_T['年末总人口(万人)'])
plt.axhline(y=0.5,color='red')
plt.title('男性人口占比')
plt.show()


plt.figure(figsize=(12,4))#画布设置

plt.plot(df_total_T['城镇人口(万人)_pct'],label='城镇环比')
plt.plot(df_total_T['乡村人口(万人)_pct'],label='乡村环比')
plt.plot(df_total_T['年末总人口(万人)_pct'],label="总人口环比")
plt.axhline(y=0,color='red')#正负值红线

plt.legend()
plt.title('城镇化环比速度')
plt.show()


df_ngr=pd.read_csv("/home/mw/input/population5417/出生率死亡率自然增长率.csv",encoding='gbk',index_col=0)#数据框加载
df_ngr_T=df_ngr.T#数据框转置
df_ngr_T=df_ngr_T.sort_index()#按年升序排列
df_ngr_T=df_ngr_T.dropna(how="all")#删除全是空值的行
df_ngr_T


plt.figure(figsize=(12,6))#设置画布

plt.plot(df_ngr_T)
plt.axhline(y=0,color='red')#正负值红线

plt.legend(['人口出生率(‰)','人口死亡率(‰)','人口自然增长率(‰)','0线'])#图例设置
plt.title("出生率死亡率自然增长率趋势")#标题设置
plt.show()


df_age=pd.read_csv("/home/mw/input/population5417/人口年龄分布.csv",encoding='gbk',index_col=0)#加载数据
df_age_T=df_age.T#数据框转置
df_age_T=df_age_T.sort_index()#按年升序排列
df_age_T=df_age_T.dropna(how="all")#去全空值行
df_age_T.head(2)


l_male=df_age_male_T.columns.to_list()
print("low:",l_male.index('20-24岁男性人口数(人口抽样调查)(人)'))#20-24岁男性人口数(人口抽样调查)(人)在数据框列中的索引位置数值
print("high:",l_male.index('50-54岁男性人口数(人口抽样调查)(人)'))#50-54岁男性人口数(人口抽样调查)(人)在数据框列中的索引位置数值
df_age_male_T['男性适婚适孕']=df_age_male_T.iloc[:,5:12].sum(axis=1)#设置字段男性适婚适孕并赋值


df_age_female=pd.read_csv("/home/mw/input/population5417/女性年龄分布.csv",encoding='gbk',index_col=0)
df_age_female_T=df_age_female.T
df_age_female_T=df_age_female_T.sort_index()
df_age_female_T=df_age_female_T.dropna(how="all")
df_age_female_T.head(2)


df_edu_T.columns


设置6岁及6岁以上未上过学人口占比(人口抽样调查)字段并赋值
df_edu_T['6岁及6岁以上未上过学人口占比(人口抽样调查)']=df_edu_T['6岁及6岁以上未上过学人口数(人口抽样调查)(人)']/df_edu_T['6岁及6岁以上人口数(人口抽样调查)(人)']


plt.figure(figsize=(12,6))

plt.plot(df_edu_T['6岁及6岁以上未上过学人口占比(人口抽样调查)'],label="未上过学人口占比")
#plt.plot(df_edu_T['6岁及6岁以上未上过学女性人口占比(人口抽样调查)'],label="未上过学女性人口占比")

plt.legend()
plt.title("6岁及6岁以上未上过学人口占比(人口抽样调查)")
plt.show()

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/9/26 18:14:35

Steamless终极指南:轻松移除Steam游戏DRM保护

Steamless终极指南:轻松移除Steam游戏DRM保护 【免费下载链接】Steamless Steamless is a DRM remover of the SteamStub variants. The goal of Steamless is to make a single solution for unpacking all Steam DRM-packed files. Steamless aims to support as …

作者头像 李华
网站建设 2026/9/26 23:43:59

图像对比工具在网络安全配置中的高效应用与优化策略

图像对比工具在网络安全配置中的高效应用与优化策略 【免费下载链接】image-compare-viewer Compare before and after images, for grading and other retouching for instance. Vanilla JS, zero dependencies. 项目地址: https://gitcode.com/gh_mirrors/im/image-compare…

作者头像 李华
网站建设 2026/9/27 8:32:50

终极指南:macOS iSCSI Initiator快速连接远程存储

终极指南:macOS iSCSI Initiator快速连接远程存储 【免费下载链接】iSCSIInitiator iSCSI Initiator for macOS 项目地址: https://gitcode.com/gh_mirrors/is/iSCSIInitiator macOS iSCSI Initiator是一款功能强大的开源软件,专门为苹果电脑用户…

作者头像 李华
网站建设 2026/9/27 3:46:56

FastDepth:嵌入式系统上的快速单目深度估计

FastDepth:嵌入式系统上的快速单目深度估计 【免费下载链接】fast-depth ICRA 2019 "FastDepth: Fast Monocular Depth Estimation on Embedded Systems" 项目地址: https://gitcode.com/gh_mirrors/fa/fast-depth FastDepth 是一个专门为嵌入式系…

作者头像 李华