{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": "# Quickstart: Ziplore US ZIP Codes with Census Demographics (41,682 ZIPs)\n\nA free, current replacement for the frozen ZIP data inside uszipcode (last release 2022), pyzipcode (2021) and the zipcodes npm package (2018).\n\nDataset: [huggingface.co/datasets/CyberMax-tools/us-zip-codes-demographics](https://huggingface.co/datasets/CyberMax-tools/us-zip-codes-demographics) · file: `zips.csv` · by CyberMax.\n\nRuns anywhere with pandas (Colab, Kaggle, Jupyter, VS Code). The outputs below are from a real run of this notebook." }, { "cell_type": "markdown", "metadata": {}, "source": "## Load the data" }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "output_type": "stream", "name": "stdout", "text": "41,682 rows x 25 columns\n" }, { "output_type": "execute_result", "execution_count": 1, "metadata": {}, "data": { "text/plain": " zip ... counties\n0 501 ... NaN\n1 544 ... NaN\n2 601 ... 72001:0.988;72141:0.012\n3 602 ... 72003:1.000;72011:0.000\n4 603 ... 72005:0.998;72099:0.002\n5 604 ... NaN\n6 605 ... NaN\n7 606 ... 72093:0.823;72153:0.117;72121:0.061\n8 610 ... 72011:0.968;72099:0.028;72083:0.004;72003:0.001\n9 611 ... 72141:1.000\n\n[10 rows x 25 columns]", "text/html": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
zipcitystatestateNamestateFipscounty...medianGrossRenthousingUnitsoccupiedUnitsownerOccupiedUnitsownerOccupiedPctcounties
0501HoltsvilleNYNew York36.0Suffolk County...NaNNaNNaNNaNNaNNaN
1544HoltsvilleNYNew York36.0Suffolk County...NaNNaNNaNNaNNaNNaN
2601AdjuntasPRPuerto Rico72.0Adjuntas Municipio...427.07570.05768.03891.067.572001:0.988;72141:0.012
3602AguadaPRPuerto Rico72.0Aguada Municipio...475.017610.012954.09529.073.672003:1.000;72011:0.000
4603AguadillaPRPuerto Rico72.0Aguadilla Municipio...475.026239.020131.011531.057.372005:0.998;72099:0.002
5604AguadillaPRPuerto Rico72.0Aguadilla Municipio...NaNNaNNaNNaNNaNNaN
6605AguadillaPRPuerto Rico72.0Aguadilla Municipio...NaNNaNNaNNaNNaNNaN
7606MaricaoPRPuerto Rico72.0Maricao Municipio...413.02681.01860.01479.079.572093:0.823;72153:0.117;72121:0.061
8610AnascoPRPuerto Rico72.0Añasco Municipio...579.012636.09604.06879.071.672011:0.968;72099:0.028;72083:0.004;72003:0.001
9611AngelesPRPuerto Rico72.0Utuado Municipio...470.0776.0679.0429.063.272141:1.000
" } } ], "source": "import pandas as pd\n\nURL = \"https://huggingface.co/datasets/CyberMax-tools/us-zip-codes-demographics/resolve/main/zips.csv\"\ndf = pd.read_csv(URL)\nprint(f\"{len(df):,} rows x {len(df.columns)} columns\")\ndf.head(10)" }, { "cell_type": "markdown", "metadata": {}, "source": "Summary statistics for the numeric columns:" }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "output_type": "execute_result", "execution_count": 2, "metadata": {}, "data": { "text/plain": " stateFips countyFips latitude longitude landSqMi waterSqMi\ncount 41173.000 41173.000 41682.000 41682.000 33791.000 33791.000\nmean 29.484 29568.102 38.458 -89.461 83.582 1.953\nstd 15.761 15774.006 5.829 22.055 234.252 13.823\nmin 1.000 1001.000 -89.998 -177.389 0.001 0.000\n25% 17.000 17131.000 34.954 -97.190 8.116 0.017\n50% 29.000 29183.000 39.118 -87.730 34.892 0.205\n75% 42.000 42057.000 41.905 -79.867 87.036 1.029\nmax 78.000 78030.000 76.531 178.878 13680.117 1426.087", "text/html": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
stateFipscountyFipslatitudelongitudelandSqMiwaterSqMi
count41173.00041173.00041682.00041682.00033791.00033791.000
mean29.48429568.10238.458-89.46183.5821.953
std15.76115774.0065.82922.055234.25213.823
min1.0001001.000-89.998-177.3890.0010.000
25%17.00017131.00034.954-97.1908.1160.017
50%29.00029183.00039.118-87.73034.8920.205
75%42.00042057.00041.905-79.86787.0361.029
max78.00078030.00076.531178.87813680.1171426.087
" } } ], "source": "df[['stateFips', 'countyFips', 'latitude', 'longitude', 'landSqMi', 'waterSqMi']].describe().round(3)" }, { "cell_type": "markdown", "metadata": {}, "source": "## Go further\n- **All CyberMax tools, datasets and free apps:** [https://cybermax-tools-cybermax.static.hf.space/](https://cybermax-tools-cybermax.static.hf.space/)" } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }