美國各郵遞區號 2000 和 2010 年十年一度普查的美國人口數 (依性別和種族)。
此資料集的來源是美國普查局十年一次的普查資料集 API。 如需此資料集相關的使用條款及條件,請參閱服務條款及政策與聲明。
注意
Microsoft 依「現況」提供 Azure 開放資料集。 針對 貴用戶對資料集的使用方式,Microsoft 不提供任何明示或默示的擔保、保證或條件。 在 貴用戶當地法律允許的範圍內,針對因使用資料集而導致的任何直接性、衍生性、特殊性、間接性、附隨性或懲罰性損害或損失,Microsoft 概不承擔任何責任。
此資料集是根據 Microsoft 接收來源資料的原始條款所提供。 資料集可能包含源自 Microsoft 的資料。
資料量與保留期
此資料集以 Parquet 格式儲存,並含有 2010 年的資料。
儲存位置
此資料集儲存於美國東部 Azure 區域。 建議您在美國東部配置計算資源,以確保同質性。
資料行
名稱 |
資料類型 |
唯一 |
Values (sample) |
描述 |
decennialTime |
字串 |
1 |
2010 |
十年一度普查年份,例如,2010 年、2000 年。 |
maxAge |
int |
23 |
54 21 |
年齡範圍最大值。 如果是 null,就表示跨所有年齡,或年齡範圍沒有上限,例如,年齡 > 85。 |
minAge |
int |
23 |
45 30 |
年齡範圍最小值。 如果是 null,就表示跨所有年齡。 |
母體 |
int |
29,274 |
1 和 2 |
此區段的人口數。 |
race |
字串 |
8 |
一些其他種族,僅限黑人或非裔美國人 |
人口普查資料的種族類別。 如果是 null,就表示跨所有種族。 |
sex |
字串 |
3 |
女性男性 |
男性或女性。 如果是 null,就表示跨兩種性別。 |
year |
int |
1 |
2010 |
十年一度的年份 (整數)。 |
zipCode |
字串 |
33,120 |
39218 87420 |
5 位數郵遞區號製表區域 (ZCTA5)。 |
預覽
decennialTime |
zipCode |
母體 |
race |
sex |
minAge |
maxAge |
year |
2010 |
77477 |
265 |
僅限白人 |
女性 |
15 |
17 |
2010 |
2010 |
77477 |
107 |
僅一些其他種族 |
女性 |
15 |
17 |
2010 |
2010 |
77477 |
12 |
僅一些其他種族 |
女性 |
65 |
66 |
2010 |
2010 |
77477 |
101 |
僅限亞洲人 |
女性 |
60 |
61 |
2010 |
2010 |
77477 |
221 |
僅限亞洲人 |
男性 |
10 |
14 |
2010 |
2010 |
77478 |
256 |
僅限白人 |
女性 |
15 |
17 |
2010 |
2010 |
77478 |
17 |
僅一些其他種族 |
女性 |
15 |
17 |
2010 |
2010 |
77478 |
3 |
僅一些其他種族 |
女性 |
65 |
66 |
2010 |
資料存取
Azure Notebooks
# This is a package in preview.
from azureml.opendatasets import UsPopulationZip
population = UsPopulationZip()
population_df = population.to_pandas_dataframe()
population_df.info()
# Pip install packages
import os, sys
!{sys.executable} -m pip install azure-storage-blob
!{sys.executable} -m pip install pyarrow
!{sys.executable} -m pip install pandas
# Azure storage access info
azure_storage_account_name = "azureopendatastorage"
azure_storage_sas_token = r""
container_name = "censusdatacontainer"
folder_name = "release/us_population_zip/"
from azure.storage.blob import BlockBlobServicefrom azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
if azure_storage_account_name is None or azure_storage_sas_token is None:
raise Exception(
"Provide your specific name and key for your Azure Storage account--see the Prerequisites section earlier.")
print('Looking for the first parquet under the folder ' +
folder_name + ' in container "' + container_name + '"...')
container_url = f"https://{azure_storage_account_name}.blob.core.windows.net/"
blob_service_client = BlobServiceClient(
container_url, azure_storage_sas_token if azure_storage_sas_token else None)
container_client = blob_service_client.get_container_client(container_name)
blobs = container_client.list_blobs(folder_name)
sorted_blobs = sorted(list(blobs), key=lambda e: e.name, reverse=True)
targetBlobName = ''
for blob in sorted_blobs:
if blob.name.startswith(folder_name) and blob.name.endswith('.parquet'):
targetBlobName = blob.name
break
print('Target blob to download: ' + targetBlobName)
_, filename = os.path.split(targetBlobName)
blob_client = container_client.get_blob_client(targetBlobName)
with open(filename, 'wb') as local_file:
blob_client.download_blob().download_to_stream(local_file)
# Read the parquet file into Pandas data frame
import pandas as pd
print('Reading the parquet file into Pandas data frame')
df = pd.read_parquet(filename)
# you can add your filter at below
print('Loaded as a Pandas data frame: ')
df
Azure Databricks
# This is a package in preview.
from azureml.opendatasets import UsPopulationZip
population = UsPopulationZip()
population_df = population.to_spark_dataframe()
display(population_df.limit(5))
# Azure storage access info
blob_account_name = "azureopendatastorage"
blob_container_name = "censusdatacontainer"
blob_relative_path = "release/us_population_zip/"
blob_sas_token = r""
# Allow SPARK to read from Blob remotely
wasbs_path = 'wasbs://%s@%s.blob.core.windows.net/%s' % (blob_container_name, blob_account_name, blob_relative_path)
spark.conf.set(
'fs.azure.sas.%s.%s.blob.core.windows.net' % (blob_container_name, blob_account_name),
blob_sas_token)
print('Remote blob path: ' + wasbs_path)
# SPARK read parquet, note that it won't load any data yet by now
df = spark.read.parquet(wasbs_path)
print('Register the DataFrame as a SQL temporary view: source')
df.createOrReplaceTempView('source')
# Display top 10 rows
print('Displaying top 10 rows: ')
display(spark.sql('SELECT * FROM source LIMIT 10'))
Azure Synapse
# This is a package in preview.
from azureml.opendatasets import UsPopulationZip
population = UsPopulationZip()
population_df = population.to_spark_dataframe()
# Display top 5 rows
display(population_df.limit(5))
# Azure storage access info
blob_account_name = "azureopendatastorage"
blob_container_name = "censusdatacontainer"
blob_relative_path = "release/us_population_zip/"
blob_sas_token = r""
# Allow SPARK to read from Blob remotely
wasbs_path = 'wasbs://%s@%s.blob.core.windows.net/%s' % (blob_container_name, blob_account_name, blob_relative_path)
spark.conf.set(
'fs.azure.sas.%s.%s.blob.core.windows.net' % (blob_container_name, blob_account_name),
blob_sas_token)
print('Remote blob path: ' + wasbs_path)
# SPARK read parquet, note that it won't load any data yet by now
df = spark.read.parquet(wasbs_path)
print('Register the DataFrame as a SQL temporary view: source')
df.createOrReplaceTempView('source')
# Display top 10 rows
print('Displaying top 10 rows: ')
display(spark.sql('SELECT * FROM source LIMIT 10'))
下一步
檢視開放資料集目錄中的其餘資料集。