CyberMax-tools commited on
Commit
3fb4552
·
verified ·
1 Parent(s): 157a197

Add a tested pandas quickstart notebook

Browse files
Files changed (2) hide show
  1. README.md +6 -0
  2. notebooks/quickstart.ipynb +75 -0
README.md CHANGED
@@ -77,6 +77,12 @@ This table is published under CC BY 4.0: credit "Ziplore by CyberMax, with data
77
  - [Fipsbook: US Census Geographies with FIPS Codes, Centroids & Land Area (2025)](https://huggingface.co/datasets/CyberMax-tools/fipsbook-us-census-geographies)
78
  <!-- cybermax-xlinks:end -->
79
 
 
 
 
 
 
 
80
  <!-- cybermax-web:start -->
81
  ## Browse it on the web
82
 
 
77
  - [Fipsbook: US Census Geographies with FIPS Codes, Centroids & Land Area (2025)](https://huggingface.co/datasets/CyberMax-tools/fipsbook-us-census-geographies)
78
  <!-- cybermax-xlinks:end -->
79
 
80
+ <!-- cybermax-notebook:start -->
81
+ ## Quickstart notebook
82
+
83
+ Load this dataset with pandas and see real outputs in the [quickstart notebook](https://huggingface.co/datasets/CyberMax-tools/us-zip-codes-demographics/blob/main/notebooks/quickstart.ipynb).
84
+ <!-- cybermax-notebook:end -->
85
+
86
  <!-- cybermax-web:start -->
87
  ## Browse it on the web
88
 
notebooks/quickstart.ipynb ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "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."
7
+ },
8
+ {
9
+ "cell_type": "markdown",
10
+ "metadata": {},
11
+ "source": "## Load the data"
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 1,
16
+ "metadata": {},
17
+ "outputs": [
18
+ {
19
+ "output_type": "stream",
20
+ "name": "stdout",
21
+ "text": "41,682 rows x 25 columns\n"
22
+ },
23
+ {
24
+ "output_type": "execute_result",
25
+ "execution_count": 1,
26
+ "metadata": {},
27
+ "data": {
28
+ "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]",
29
+ "text/html": "<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>zip</th>\n <th>city</th>\n <th>state</th>\n <th>stateName</th>\n <th>stateFips</th>\n <th>county</th>\n <th>...</th>\n <th>medianGrossRent</th>\n <th>housingUnits</th>\n <th>occupiedUnits</th>\n <th>ownerOccupiedUnits</th>\n <th>ownerOccupiedPct</th>\n <th>counties</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>501</td>\n <td>Holtsville</td>\n <td>NY</td>\n <td>New York</td>\n <td>36.0</td>\n <td>Suffolk County</td>\n <td>...</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>1</th>\n <td>544</td>\n <td>Holtsville</td>\n <td>NY</td>\n <td>New York</td>\n <td>36.0</td>\n <td>Suffolk County</td>\n <td>...</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>2</th>\n <td>601</td>\n <td>Adjuntas</td>\n <td>PR</td>\n <td>Puerto Rico</td>\n <td>72.0</td>\n <td>Adjuntas Municipio</td>\n <td>...</td>\n <td>427.0</td>\n <td>7570.0</td>\n <td>5768.0</td>\n <td>3891.0</td>\n <td>67.5</td>\n <td>72001:0.988;72141:0.012</td>\n </tr>\n <tr>\n <th>3</th>\n <td>602</td>\n <td>Aguada</td>\n <td>PR</td>\n <td>Puerto Rico</td>\n <td>72.0</td>\n <td>Aguada Municipio</td>\n <td>...</td>\n <td>475.0</td>\n <td>17610.0</td>\n <td>12954.0</td>\n <td>9529.0</td>\n <td>73.6</td>\n <td>72003:1.000;72011:0.000</td>\n </tr>\n <tr>\n <th>4</th>\n <td>603</td>\n <td>Aguadilla</td>\n <td>PR</td>\n <td>Puerto Rico</td>\n <td>72.0</td>\n <td>Aguadilla Municipio</td>\n <td>...</td>\n <td>475.0</td>\n <td>26239.0</td>\n <td>20131.0</td>\n <td>11531.0</td>\n <td>57.3</td>\n <td>72005:0.998;72099:0.002</td>\n </tr>\n <tr>\n <th>5</th>\n <td>604</td>\n <td>Aguadilla</td>\n <td>PR</td>\n <td>Puerto Rico</td>\n <td>72.0</td>\n <td>Aguadilla Municipio</td>\n <td>...</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>6</th>\n <td>605</td>\n <td>Aguadilla</td>\n <td>PR</td>\n <td>Puerto Rico</td>\n <td>72.0</td>\n <td>Aguadilla Municipio</td>\n <td>...</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>7</th>\n <td>606</td>\n <td>Maricao</td>\n <td>PR</td>\n <td>Puerto Rico</td>\n <td>72.0</td>\n <td>Maricao Municipio</td>\n <td>...</td>\n <td>413.0</td>\n <td>2681.0</td>\n <td>1860.0</td>\n <td>1479.0</td>\n <td>79.5</td>\n <td>72093:0.823;72153:0.117;72121:0.061</td>\n </tr>\n <tr>\n <th>8</th>\n <td>610</td>\n <td>Anasco</td>\n <td>PR</td>\n <td>Puerto Rico</td>\n <td>72.0</td>\n <td>Añasco Municipio</td>\n <td>...</td>\n <td>579.0</td>\n <td>12636.0</td>\n <td>9604.0</td>\n <td>6879.0</td>\n <td>71.6</td>\n <td>72011:0.968;72099:0.028;72083:0.004;72003:0.001</td>\n </tr>\n <tr>\n <th>9</th>\n <td>611</td>\n <td>Angeles</td>\n <td>PR</td>\n <td>Puerto Rico</td>\n <td>72.0</td>\n <td>Utuado Municipio</td>\n <td>...</td>\n <td>470.0</td>\n <td>776.0</td>\n <td>679.0</td>\n <td>429.0</td>\n <td>63.2</td>\n <td>72141:1.000</td>\n </tr>\n </tbody>\n</table>"
30
+ }
31
+ }
32
+ ],
33
+ "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)"
34
+ },
35
+ {
36
+ "cell_type": "markdown",
37
+ "metadata": {},
38
+ "source": "Summary statistics for the numeric columns:"
39
+ },
40
+ {
41
+ "cell_type": "code",
42
+ "execution_count": 2,
43
+ "metadata": {},
44
+ "outputs": [
45
+ {
46
+ "output_type": "execute_result",
47
+ "execution_count": 2,
48
+ "metadata": {},
49
+ "data": {
50
+ "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",
51
+ "text/html": "<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>stateFips</th>\n <th>countyFips</th>\n <th>latitude</th>\n <th>longitude</th>\n <th>landSqMi</th>\n <th>waterSqMi</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>count</th>\n <td>41173.000</td>\n <td>41173.000</td>\n <td>41682.000</td>\n <td>41682.000</td>\n <td>33791.000</td>\n <td>33791.000</td>\n </tr>\n <tr>\n <th>mean</th>\n <td>29.484</td>\n <td>29568.102</td>\n <td>38.458</td>\n <td>-89.461</td>\n <td>83.582</td>\n <td>1.953</td>\n </tr>\n <tr>\n <th>std</th>\n <td>15.761</td>\n <td>15774.006</td>\n <td>5.829</td>\n <td>22.055</td>\n <td>234.252</td>\n <td>13.823</td>\n </tr>\n <tr>\n <th>min</th>\n <td>1.000</td>\n <td>1001.000</td>\n <td>-89.998</td>\n <td>-177.389</td>\n <td>0.001</td>\n <td>0.000</td>\n </tr>\n <tr>\n <th>25%</th>\n <td>17.000</td>\n <td>17131.000</td>\n <td>34.954</td>\n <td>-97.190</td>\n <td>8.116</td>\n <td>0.017</td>\n </tr>\n <tr>\n <th>50%</th>\n <td>29.000</td>\n <td>29183.000</td>\n <td>39.118</td>\n <td>-87.730</td>\n <td>34.892</td>\n <td>0.205</td>\n </tr>\n <tr>\n <th>75%</th>\n <td>42.000</td>\n <td>42057.000</td>\n <td>41.905</td>\n <td>-79.867</td>\n <td>87.036</td>\n <td>1.029</td>\n </tr>\n <tr>\n <th>max</th>\n <td>78.000</td>\n <td>78030.000</td>\n <td>76.531</td>\n <td>178.878</td>\n <td>13680.117</td>\n <td>1426.087</td>\n </tr>\n </tbody>\n</table>"
52
+ }
53
+ }
54
+ ],
55
+ "source": "df[['stateFips', 'countyFips', 'latitude', 'longitude', 'landSqMi', 'waterSqMi']].describe().round(3)"
56
+ },
57
+ {
58
+ "cell_type": "markdown",
59
+ "metadata": {},
60
+ "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/)"
61
+ }
62
+ ],
63
+ "metadata": {
64
+ "kernelspec": {
65
+ "display_name": "Python 3",
66
+ "language": "python",
67
+ "name": "python3"
68
+ },
69
+ "language_info": {
70
+ "name": "python"
71
+ }
72
+ },
73
+ "nbformat": 4,
74
+ "nbformat_minor": 5
75
+ }