【数据分享】第六次、第七次人口普查深圳各街道数据

0. 数据来源

https://tjgb.hongheiku.com/
https://www.hongheiku.com/sichuan/55201.html
手动收集整理
数据展示
在这里插入图片描述
数据分享
只分享人口数据,地理数据可能涉及隐私问题,暂不分享,有需要可以邮箱联系uncodong@qq.com

链接: https://pan.baidu.com/s/1tWyVmcmho62I248zP1rIdQ 
提取码: iknp

1. 整合成excel并使用geopandas映射

第六次人口普查数据读取

import pandas as pd

df = pd.read_excel("深圳市第六次人口普查数据记录.xlsx", sheet_name=None)
print(list(df))

统计人数并拼接

import pandas as pd


# dropnan https://blog.csdn.net/qq_17753903/article/details/89817371
# pandas合并excel的多个sheet https://blog.csdn.net/qiuqiuit/article/details/120596158
# concat https://blog.csdn.net/qsx123432/article/details/111931323
# pd.concat( [df数据1, df数据2, …… ], axis = 0或1, join = 连接方式, keys = 表明数据来源 )

## 1. 读取并拼接数据
dfs = [sheet.dropna(axis=0, how='any') for sheet in pd.read_excel("深圳市第六次人口普查数据记录.xlsx", sheet_name=None).values()]
dfs_concat = pd.concat(dfs)
print(len(dfs))

## 2. 遍历数据,保存地区和人口数量的对应关系
dfs_concat = dfs_concat.reset_index() # 重设index,这样才能用to_dict("index")
time6_area_name2people_num_dic_list = []
for each in dfs_concat.to_dict("index").values():
    area_name = each["地区"]
    people_num = each["常住人口"]
    time6_area_name2people_num_dic_list.append({
        "地区":area_name.replace("街道","").replace("办事处",""),
        "人口数量":int(people_num.replace("人","")),
    })
    
time6_df = pd.DataFrame(time6_area_name2people_num_dic_list)
time6_df
# time6_area_name2people_num_dic

读取街道尺度数据,拼接

import geopandas as gpd
shenzhen_subdistrict = gpd.read_file("shenzhen_subdistrict.shp")

print(shenzhen_subdistrict)

shenzhen_subdistrict_time6 = shenzhen_subdistrict.merge(time6_df, left_on='JDNAME', right_on='地区', how='left')
shenzhen_subdistrict_time6.to_file('深圳-第6次人口普查-街道.shp', driver='ESRI Shapefile', encoding='gbk')
shenzhen_subdistrict_time6

2. 地理数据展示

颜色越深表示人越多
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值