美国zipcode可编程数据库,包括最新的人口普查和几何信息。

uszipcode的Python项目详细描述


Documentation Statushttps://travis-ci.org/MacHu-GWU/uszipcode-project.svg?branch=masterhttps://codecov.io/gh/MacHu-GWU/uszipcode-project/branch/master/graph/badge.svghttps://img.shields.io/pypi/v/uszipcode.svghttps://img.shields.io/pypi/l/uszipcode.svghttps://img.shields.io/pypi/pyversions/uszipcode.svghttps://img.shields.io/badge/STAR_Me_on_GitHub!--None.svg?style=social
https://img.shields.io/badge/Link-Document-blue.svghttps://img.shields.io/badge/Link-API-blue.svghttps://img.shields.io/badge/Link-Source_Code-blue.svghttps://img.shields.io/badge/Link-Install-blue.svghttps://img.shields.io/badge/Link-GitHub-blue.svghttps://img.shields.io/badge/Link-Submit_Issue-blue.svghttps://img.shields.io/badge/Link-Request_Feature-blue.svghttps://img.shields.io/badge/Link-Download-blue.svg

欢迎使用uszipcode文档

如果您位于www.pypi.org或www.github.com,则这不是完整的文档。这是Complete Document

uszipcode是python中最强大、最易于使用的可编程zipcode数据库。它具有丰富的功能和易于使用的zipcode搜索引擎。而且很容易定制您想要的搜索行为。

数据点

从0.2.0版开始,uszipcode使用更新的数据库,每周运行一个爬网程序从多个数据源收集不同的数据点。以及0.2.x中的api与0.1.x不兼容,有关详细信息,请阅读Document

地址,邮政

  • Zipcode
  • Zipcode_类型
  • 大城市
  • 市邮政局
  • 公共城市列表
  • 状态
  • 区域代码列表

地理位置

  • 纬度
  • 液化天然气
  • 时区
  • 半径单位为英里
  • 土地面积单位:平方米
  • 水面积单位:平方米
  • 西界
  • 东界
  • 北界
  • 南界
  • 边框多边形

stats和人口统计信息

  • 人口
  • 人口密度
  • 按年份划分的人口
  • 按年龄划分的人口
  • 按性别划分的人口
  • 按种族划分的人口
  • 按年龄划分的户主
  • 家庭vs单身
  • 有孩子的家庭
  • 按年龄划分的儿童

房地产和住房

  • 住房单元
  • 居住单元
  • 居家中值
  • 家庭收入中值
  • 房型
  • 房屋建造年份
  • 住房入住率
  • 凡坎西原因
  • 业主占用房屋价值
  • 按房间数量出租房地产
  • 每月租金,包括公共设施工作室公寓
  • 每月租金,包括水电费
  • 每月租金,包括水电费
  • 每月租金,包括水电费

就业、收入、收入和工作

  • 就业状况
  • 家庭平均收入
  • 家庭收入
  • 个人年收益
  • 家庭收入来源家庭收入百分比
  • 家庭收入来源家庭平均收入来源
  • 家庭投资收入占接受投资家庭收入的百分比
  • 家庭投资收入收入来源家庭平均收入
  • 家庭退休收入占领取退休收入家庭的百分比
  • 家庭退休收入家庭平均收入来源
  • 收入来源
  • 是指为16岁以上的工人提供从交通到工作的交通工具
  • 旅行时间到工作时间(单位:分钟)

教育

  • 25岁及以上人口的教育程度
  • 入学年龄从3岁到17岁

示例用法

注释

^{tt1}$ has two backend database, ^{tt5}$ and ^{tt6}$. ^{tt6}$ has more info, but the database file is 450MB (takes more time to download). ^{tt5}$ doesn’t has all data points listed above, but the database file is smaller (9MB). By default ^{tt1}$ use ^{tt5}$. You can use this code to choose to use the rich info ^{tt6}$:

>>> from uszipcode import SearchEngine
>>> search = SearchEngine(simple_zipcode=False)

示例

>>>fromuszipcodeimportSearchEngine>>>search=SearchEngine(simple_zipcode=True)# set simple_zipcode=False to use rich info database>>>zipcode=search.by_zipcode("10001")>>>zipcodeSimpleZipcode(zipcode=u'10001',zipcode_type=u'Standard',major_city=u'New York',post_office_city=u'New York, NY',common_city_list=[u'New York'],county=u'New York County',state=u'NY',lat=40.75,lng=-73.99,timezone=u'Eastern',radius_in_miles=0.9090909090909091,area_code_list=[u'718',u'917',u'347',u'646'],population=21102,population_density=33959.0,land_area_in_sqmi=0.62,water_area_in_sqmi=0.0,housing_units=12476,occupied_housing_units=11031,median_home_value=650200,median_household_income=81671,bounds_west=-74.008621,bounds_east=-73.984076,bounds_north=40.759731,bounds_south=40.743451)>>>zipcode.values()# to list[u'10001',u'Standard',u'New York',u'New York, NY',[u'New York'],u'New York County',u'NY',40.75,-73.99,u'Eastern',0.9090909090909091,[u'718',u'917',u'347',u'646'],21102,33959.0,0.62,0.0,12476,11031,650200,81671,-74.008621,-73.984076,40.759731,40.743451]>>>zipcode.to_dict()# to dict{'housing_units':12476,'post_office_city':u'New York, NY','bounds_east':-73.984076,'county':u'New York County','population_density':33959.0,'radius_in_miles':0.9090909090909091,'timezone':u'Eastern','lng':-73.99,'common_city_list':[u'New York'],'zipcode_type':u'Standard','zipcode':u'10001','state':u'NY','major_city':u'New York','population':21102,'bounds_west':-74.008621,'land_area_in_sqmi':0.62,'lat':40.75,'median_household_income':81671,'occupied_housing_units':11031,'bounds_north':40.759731,'bounds_south':40.743451,'area_code_list':[u'718',u'917',u'347',u'646'],'median_home_value':650200,'water_area_in_sqmi':0.0}>>>zipcode.to_json()# to json{"zipcode":"10001","zipcode_type":"Standard","major_city":"New York","post_office_city":"New York, NY","common_city_list":["New York"],"county":"New York County","state":"NY","lat":40.75,"lng":-73.99,"timezone":"Eastern","radius_in_miles":0.9090909090909091,"area_code_list":["718","917","347","646"],"population":21102,"population_density":33959.0,"land_area_in_sqmi":0.62,"water_area_in_sqmi":0.0,"housing_units":12476,"occupied_housing_units":11031,"median_home_value":650200,"median_household_income":81671,"bounds_west":-74.008621,"bounds_east":-73.984076,"bounds_north":40.759731,"bounds_south":40.743451}

我们提供了丰富的搜索方法来按照您想要的方式获取zipcode。

>>>fromuszipcodeimportZipcode# Search zipcode within 30 miles, ordered from closest to farthest>>>result=search.by_coordinates(39.122229,-77.133578,radius=30,returns=5)>>>len(res)# by default 5 results returned5>>>forzipcodeinresult:...# do whatever you want...# Find top 10 population zipcode>>>result=search.by_population(lower=0,upper=999999999,...sort_by=Zipcode.population,ascending=False,returns=10)# Find top 10 largest land area zipcode>>>res=search.by_landarea(lower=0,upper=999999999,...sort_by=Zipcode.land_area_in_sqmi,ascending=False,returns=10)

模糊城市名和州名搜索不需要开发人员知道城市或州的确切拼写。它是大小写的,不区分空间,对排版有很高的容忍度。如果你需要用它来构建一个web应用程序,这是非常有用的。

# Looking for Chicago and IL, but entered wrong spelling.>>>res=search.by_city_and_state("cicago","il")>>>len(res)# 56 zipcodes in Chicago56>>>zipcode=res[0]>>>zipcode.major_city'Chicago'>>>zipcode.state_abbr'IL'

您可以轻松地按任何字段对结果进行排序,如果按位置查询,则可以按距坐标的距离进行排序。

# Find top 10 population zipcode>>>res=search.by_population(lower=0,upper=999999999,...sort_by=Zipcode.population,ascending=False,returns=10)>>>forzipcodeinres:...# do whatever you want...

安装

uszipcode在pypi上发布,所以您只需要:

$ pip install uszipcode

要升级到最新版本:

$ pip install --upgrade uszipcode

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
选择java还是php for GWT!   java渲染为半大小的帧缓冲区,然后将其放大以实现像素化外观   apt如何使用Java镜像API确定该类是抽象的?   如何在HTTPS中正确地将来自客户端的消息转发到Web服务器?(Java代理服务器)   使用类路径上使用JDK 8构建的类编译面向1.7的Java类   java如何为这段代码编写一个简单的输入验证   用于platformer游戏地图的java数据结构   java如何获取SortedSet的下一个元素?   java为什么我在文本文档中保存按钮单击的方法不能正常工作?   java如何使用twitter4j。地位isRetweet()方法   将数据添加到TableViewer时出现java异常   JavaSpringFramework 3.2.5对PostAPI输出的响应体进行解码   java如何创建按钮的自定义形状,同时保持按钮的可点击性和可聚焦性   java是一个构造函数还是一个变种人?   java Outofmemory异常使用改型库安卓   java在excel中使用宏实现双击操作   JavaAndroid:如何将枚举标签添加到微调器,而不是枚举。值()?   java ArrayList<object>inside ArrayList<anotherObject>在类中,以在RecyclerView中发送数据   java Eclipse未打开框架窗口