diff --git a/us/poverty/state_poverty_rates.ipynb b/us/poverty/state_poverty_rates.ipynb
new file mode 100644
index 0000000..edf2f93
--- /dev/null
+++ b/us/poverty/state_poverty_rates.ipynb
@@ -0,0 +1,6053 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "cell-0",
+ "metadata": {},
+ "source": [
+ "# Poverty and Child Poverty Rates by State\n",
+ "\n",
+ "This notebook calculates SPM poverty and child poverty rates for all 50 US states plus Washington DC using PolicyEngine microsimulation.\n",
+ "\n",
+ "**Methodology:**\n",
+ "- Uses `person_in_poverty` variable (SPM poverty definition)\n",
+ "- Child poverty: persons under age 18 in poverty\n",
+ "- Weighted calculations using state-specific datasets"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "cell-1",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from policyengine_us import Microsimulation\n",
+ "import pandas as pd\n",
+ "import numpy as np\n",
+ "from huggingface_hub import hf_hub_download\n",
+ "import plotly.express as px\n",
+ "import plotly.graph_objects as go\n",
+ "import gc # For memory management"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "cell-2",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Configuration\n",
+ "ANALYSIS_YEAR = 2026\n",
+ "\n",
+ "# States ordered by approximate population (smallest first) to reduce early memory pressure\n",
+ "# Large states (CA, TX, FL, NY) are processed last\n",
+ "STATES = [\n",
+ " \"WY\", \"VT\", \"DC\", \"AK\", \"ND\", \"SD\", \"DE\", \"RI\", \"MT\", \"ME\",\n",
+ " \"NH\", \"HI\", \"WV\", \"ID\", \"NE\", \"NM\", \"KS\", \"MS\", \"AR\", \"NV\",\n",
+ " \"IA\", \"UT\", \"CT\", \"OK\", \"OR\", \"KY\", \"LA\", \"AL\", \"SC\", \"MN\",\n",
+ " \"CO\", \"WI\", \"MD\", \"MO\", \"TN\", \"AZ\", \"IN\", \"MA\", \"WA\", \"VA\",\n",
+ " \"NJ\", \"MI\", \"NC\", \"GA\", \"OH\", \"IL\", \"PA\", \"NY\", \"FL\", \"TX\",\n",
+ " \"CA\"\n",
+ "]\n",
+ "\n",
+ "# State names for display\n",
+ "STATE_NAMES = {\n",
+ " \"AL\": \"Alabama\", \"AK\": \"Alaska\", \"AZ\": \"Arizona\", \"AR\": \"Arkansas\",\n",
+ " \"CA\": \"California\", \"CO\": \"Colorado\", \"CT\": \"Connecticut\", \"DE\": \"Delaware\",\n",
+ " \"FL\": \"Florida\", \"GA\": \"Georgia\", \"HI\": \"Hawaii\", \"ID\": \"Idaho\",\n",
+ " \"IL\": \"Illinois\", \"IN\": \"Indiana\", \"IA\": \"Iowa\", \"KS\": \"Kansas\",\n",
+ " \"KY\": \"Kentucky\", \"LA\": \"Louisiana\", \"ME\": \"Maine\", \"MD\": \"Maryland\",\n",
+ " \"MA\": \"Massachusetts\", \"MI\": \"Michigan\", \"MN\": \"Minnesota\", \"MS\": \"Mississippi\",\n",
+ " \"MO\": \"Missouri\", \"MT\": \"Montana\", \"NE\": \"Nebraska\", \"NV\": \"Nevada\",\n",
+ " \"NH\": \"New Hampshire\", \"NJ\": \"New Jersey\", \"NM\": \"New Mexico\", \"NY\": \"New York\",\n",
+ " \"NC\": \"North Carolina\", \"ND\": \"North Dakota\", \"OH\": \"Ohio\", \"OK\": \"Oklahoma\",\n",
+ " \"OR\": \"Oregon\", \"PA\": \"Pennsylvania\", \"RI\": \"Rhode Island\", \"SC\": \"South Carolina\",\n",
+ " \"SD\": \"South Dakota\", \"TN\": \"Tennessee\", \"TX\": \"Texas\", \"UT\": \"Utah\",\n",
+ " \"VT\": \"Vermont\", \"VA\": \"Virginia\", \"WA\": \"Washington\", \"WV\": \"West Virginia\",\n",
+ " \"WI\": \"Wisconsin\", \"WY\": \"Wyoming\", \"DC\": \"District of Columbia\"\n",
+ "}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "cell-3",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def get_state_dataset(state: str) -> str:\n",
+ " \"\"\"Download state-specific dataset from Hugging Face.\"\"\"\n",
+ " filename = f\"states/{state}.h5\"\n",
+ " dataset_path = hf_hub_download(\n",
+ " repo_id=\"policyengine/policyengine-us-data\",\n",
+ " filename=filename,\n",
+ " repo_type=\"model\",\n",
+ " )\n",
+ " return dataset_path\n",
+ "\n",
+ "\n",
+ "def calculate_poverty_rates(state: str, year: int = ANALYSIS_YEAR) -> dict:\n",
+ " \"\"\"\n",
+ " Calculate poverty and child poverty rates for a state.\n",
+ " \n",
+ " Uses person_in_poverty variable (SPM poverty definition).\n",
+ " Child poverty: age < 18.\n",
+ " \n",
+ " Memory-optimized: extracts arrays immediately and cleans up simulation.\n",
+ " \"\"\"\n",
+ " # Get state dataset and run simulation\n",
+ " dataset_path = get_state_dataset(state)\n",
+ " sim = Microsimulation(dataset=dataset_path)\n",
+ " \n",
+ " # Extract arrays immediately to minimize memory footprint\n",
+ " poverty_arr = np.array(sim.calculate(\"person_in_poverty\", year).values, dtype=np.float32)\n",
+ " age_arr = np.array(sim.calculate(\"age\", year).values, dtype=np.float32)\n",
+ " weight_arr = np.array(sim.calculate(\"person_weight\", year).values, dtype=np.float32)\n",
+ " \n",
+ " # Delete simulation object and force garbage collection\n",
+ " del sim\n",
+ " gc.collect()\n",
+ " \n",
+ " # Overall poverty rate (weighted mean)\n",
+ " poverty_rate = float(np.average(poverty_arr, weights=weight_arr))\n",
+ " \n",
+ " # Child poverty rate (age < 18)\n",
+ " child_mask = age_arr < 18\n",
+ " \n",
+ " if weight_arr[child_mask].sum() > 0:\n",
+ " child_poverty_rate = float(np.average(poverty_arr[child_mask], weights=weight_arr[child_mask]))\n",
+ " else:\n",
+ " child_poverty_rate = 0.0\n",
+ " \n",
+ " # Population counts\n",
+ " total_population = float(weight_arr.sum())\n",
+ " child_population = float(weight_arr[child_mask].sum())\n",
+ " population_in_poverty = float((poverty_arr * weight_arr).sum())\n",
+ " children_in_poverty = float((poverty_arr[child_mask] * weight_arr[child_mask]).sum())\n",
+ " \n",
+ " # Clean up arrays\n",
+ " del poverty_arr, age_arr, weight_arr, child_mask\n",
+ " gc.collect()\n",
+ " \n",
+ " return {\n",
+ " \"state\": state,\n",
+ " \"state_name\": STATE_NAMES[state],\n",
+ " \"poverty_rate\": poverty_rate,\n",
+ " \"child_poverty_rate\": child_poverty_rate,\n",
+ " \"total_population\": total_population,\n",
+ " \"child_population\": child_population,\n",
+ " \"population_in_poverty\": population_in_poverty,\n",
+ " \"children_in_poverty\": children_in_poverty,\n",
+ " }"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "cell-4",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Calculating poverty rates for 51 jurisdictions...\n",
+ "\n",
+ "[1/51] Processing Wyoming... Poverty: 17.8%, Child: 16.0%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[2/51] Processing Vermont... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "82fd4d87b1c847f48180a09c2a9e9e71",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "VT.h5: 0%| | 0.00/8.84M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 24.8%, Child: 21.3%\n",
+ "[3/51] Processing District of Columbia... Poverty: 36.8%, Child: 29.2%\n",
+ "[4/51] Processing Alaska... Poverty: 17.1%, Child: 12.5%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[5/51] Processing North Dakota... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "431388546a66420491c85b5ba0050e17",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "ND.h5: 0%| | 0.00/8.38M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 15.4%, Child: 13.1%\n",
+ " [Checkpoint saved: 5 states]\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[6/51] Processing South Dakota... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "80fa3be65b2643bd8b25d79157b42b90",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "SD.h5: 0%| | 0.00/8.70M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 21.3%, Child: 19.2%\n",
+ "[7/51] Processing Delaware... Poverty: 29.3%, Child: 25.1%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[8/51] Processing Rhode Island... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "cd43aff10aae4a02b284f81713bda8c5",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "RI.h5: 0%| | 0.00/18.2M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 26.8%, Child: 23.3%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[9/51] Processing Montana... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "7a93fe3b93f8459699d2213e935cfeb6",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "MT.h5: 64%|######3 | 10.5M/16.5M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 22.5%, Child: 16.7%\n",
+ "[10/51] Processing Maine... Poverty: 24.8%, Child: 18.6%\n",
+ " [Checkpoint saved: 10 states]\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[11/51] Processing New Hampshire... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "26069151e4884e12972c1a48179ccd5d",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "NH.h5: 0%| | 0.00/21.0M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 12.5%, Child: 13.2%\n",
+ "[12/51] Processing Hawaii... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "699c161785054bb98df03d781df01469",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "HI.h5: 65%|######5 | 10.5M/16.1M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 33.4%, Child: 25.9%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[13/51] Processing West Virginia... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "b3c4b2d1d63f45d88bcf89b3d8f175cc",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "WV.h5: 0%| | 0.00/13.2M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 25.7%, Child: 22.4%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[14/51] Processing Idaho... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "feb6ea80310f4aa6a830763fe85cc529",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "ID.h5: 64%|######3 | 10.5M/16.4M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 21.1%, Child: 15.4%\n",
+ "[15/51] Processing Nebraska... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "ab239d97d43e4e928b897e8d1c5d9ae1",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "NE.h5: 0%| | 0.00/24.6M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 18.1%, Child: 13.0%\n",
+ " [Checkpoint saved: 15 states]\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[16/51] Processing New Mexico... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "0839f37820a34b2bb95f40cde4e34df2",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "NM.h5: 0%| | 0.00/21.6M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 27.6%, Child: 23.0%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[17/51] Processing Kansas... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "ab9b34046a5044d4ba922c60b47b2c7d",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "KS.h5: 0%| | 0.00/31.5M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 25.7%, Child: 18.2%\n",
+ "[18/51] Processing Mississippi... Poverty: 29.3%, Child: 25.5%\n",
+ "[19/51] Processing Arkansas... Poverty: 24.8%, Child: 21.1%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[20/51] Processing Nevada... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "488edaf1b56d48a2aa2246e94c58b8bc",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "NV.h5: 0%| | 0.00/35.5M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 28.5%, Child: 29.8%\n",
+ " [Checkpoint saved: 20 states]\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[21/51] Processing Iowa... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "89ae6b705fad4e8da731f0795f0e727e",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "IA.h5: 0%| | 0.00/31.5M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 20.5%, Child: 14.8%\n",
+ "[22/51] Processing Utah... Poverty: 19.8%, Child: 14.1%\n",
+ "[23/51] Processing Connecticut... Poverty: 27.9%, Child: 21.5%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[24/51] Processing Oklahoma... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "bad46c13211b4164a4b78963ac715ba9",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "OK.h5: 0%| | 0.00/38.0M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 25.5%, Child: 21.7%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[25/51] Processing Oregon... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "291d70edcd114e9da1d05372e1927220",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "OR.h5: 0%| | 0.00/52.9M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 34.3%, Child: 23.1%\n",
+ " [Checkpoint saved: 25 states]\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[26/51] Processing Kentucky... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "d294131127e04e149752808d01586c00",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "KY.h5: 0%| | 0.00/43.5M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 26.0%, Child: 20.8%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[27/51] Processing Louisiana... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "8334ce8a304c4d24a674a52e9cdd7202",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "LA.h5: 0%| | 0.00/44.0M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 29.3%, Child: 26.2%\n",
+ "[28/51] Processing Alabama... Poverty: 27.9%, Child: 21.7%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[29/51] Processing South Carolina... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "843f57222e904da89678ae0a977fbbb3",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "SC.h5: 0%| | 0.00/52.4M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 26.3%, Child: 22.3%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[30/51] Processing Minnesota... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "dc2400414a2d469fac4283246f752bc8",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "MN.h5: 0%| | 0.00/68.1M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 21.6%, Child: 14.7%\n",
+ " [Checkpoint saved: 30 states]\n",
+ "[31/51] Processing Colorado... Poverty: 25.3%, Child: 19.2%\n",
+ "[32/51] Processing Wisconsin... Poverty: 22.3%, Child: 16.1%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[33/51] Processing Maryland... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "6ec18c66e8444d95a18f6d3fb22793c4",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "MD.h5: 0%| | 0.00/76.6M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 31.1%, Child: 25.8%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[34/51] Processing Missouri... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "52e9c5a692b24690b65585a9827c7a84",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "MO.h5: 17%|#6 | 10.5M/62.6M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 23.7%, Child: 19.8%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[35/51] Processing Tennessee... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "a5818cdbf95a43ca8d355ebd6d088d07",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "TN.h5: 0%| | 0.00/73.0M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 27.7%, Child: 26.6%\n",
+ " [Checkpoint saved: 35 states]\n",
+ "[36/51] Processing Arizona... Poverty: 28.1%, Child: 26.8%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[37/51] Processing Indiana... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "42117c7f701644d58f5eba3a47a3fcd5",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "IN.h5: 0%| | 0.00/68.0M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 23.7%, Child: 19.8%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[38/51] Processing Massachusetts... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "76c08eddee9047bdbf167318d47d2378",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "MA.h5: 0%| | 0.00/83.4M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 33.1%, Child: 23.4%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[39/51] Processing Washington... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "bf22c07a2c5e48e5bf4f2e3da6f03142",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "WA.h5: 11%|# | 10.5M/95.6M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 26.9%, Child: 23.2%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[40/51] Processing Virginia... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "c09fc084ed7b46b4a2c9e926a0a70e17",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "VA.h5: 0%| | 0.00/96.3M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 28.9%, Child: 21.8%\n",
+ " [Checkpoint saved: 40 states]\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[41/51] Processing New Jersey... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "ad8c737d8e854026bd227653a54d1ee2",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "NJ.h5: 0%| | 0.00/115M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 28.0%, Child: 22.3%\n",
+ "[42/51] Processing Michigan... Poverty: 25.4%, Child: 20.7%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[43/51] Processing North Carolina... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "2607dedc5dbb4003bd19e4baafa24e35",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "NC.h5: 0%| | 0.00/111M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 26.7%, Child: 22.4%\n",
+ "[44/51] Processing Georgia... Poverty: 31.9%, Child: 27.9%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[45/51] Processing Ohio... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "3a72b953ea214c12934491f717652758",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "OH.h5: 0%| | 0.00/125M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 22.9%, Child: 19.9%\n",
+ " [Checkpoint saved: 45 states]\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[46/51] Processing Illinois... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "5660cf54aca344509bd89bb2a845fe3f",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "IL.h5: 0%| | 0.00/148M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 27.4%, Child: 20.6%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[47/51] Processing Pennsylvania... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "885fe439e73d4e1186b5aaee72f3d798",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "PA.h5: 0%| | 0.00/144M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 26.6%, Child: 21.4%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[48/51] Processing New York... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "0544a007c486440ea5b480fb51bbb9df",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "NY.h5: 0%| | 0.00/228M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 35.4%, Child: 28.8%\n",
+ "[49/51] Processing Florida... Poverty: 31.8%, Child: 34.9%\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[50/51] Processing Texas... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "c63061b092ca4e8e844b3baa6837b98e",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "TX.h5: 0%| | 0.00/355M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Poverty: 30.4%, Child: 29.2%\n",
+ " [Checkpoint saved: 50 states]\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[51/51] Processing California... "
+ ]
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "5fe385ce5df84df69cd53c4331476ed7",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "CA.h5: 0%| | 0.00/473M [00:00, ?B/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ERROR: Unable to allocate 1.21 MiB for an array with shape (316717,) and data type float32\n",
+ "\n",
+ "Completed 50 of 51 states.\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Calculate poverty rates for all states with memory optimization\n",
+ "# Set RESUME=True to continue from checkpoint if kernel crashed\n",
+ "RESUME = False\n",
+ "\n",
+ "intermediate_file = f\"state_poverty_rates_{ANALYSIS_YEAR}_partial.csv\"\n",
+ "\n",
+ "# Load checkpoint if resuming\n",
+ "results = []\n",
+ "completed_states = set()\n",
+ "if RESUME:\n",
+ " try:\n",
+ " checkpoint_df = pd.read_csv(intermediate_file)\n",
+ " results = checkpoint_df.to_dict('records')\n",
+ " completed_states = set(checkpoint_df['state'].tolist())\n",
+ " print(f\"Resumed from checkpoint: {len(results)} states already completed\")\n",
+ " except FileNotFoundError:\n",
+ " print(\"No checkpoint found, starting fresh\")\n",
+ "\n",
+ "print(f\"Calculating poverty rates for {len(STATES)} jurisdictions...\\n\")\n",
+ "\n",
+ "for i, state in enumerate(STATES):\n",
+ " if state in completed_states:\n",
+ " print(f\"[{i+1}/{len(STATES)}] {STATE_NAMES[state]} - already completed, skipping\")\n",
+ " continue\n",
+ " \n",
+ " print(f\"[{i+1}/{len(STATES)}] Processing {STATE_NAMES[state]}...\", end=\" \")\n",
+ " try:\n",
+ " state_results = calculate_poverty_rates(state, ANALYSIS_YEAR)\n",
+ " results.append(state_results)\n",
+ " print(f\"Poverty: {state_results['poverty_rate']:.1%}, Child: {state_results['child_poverty_rate']:.1%}\")\n",
+ " \n",
+ " # Save checkpoint every 5 new states\n",
+ " if len(results) % 5 == 0:\n",
+ " pd.DataFrame(results).to_csv(intermediate_file, index=False)\n",
+ " print(f\" [Checkpoint saved: {len(results)} states]\")\n",
+ " \n",
+ " except Exception as e:\n",
+ " print(f\"ERROR: {e}\")\n",
+ " \n",
+ " # Force garbage collection after each state\n",
+ " gc.collect()\n",
+ "\n",
+ "# Final save\n",
+ "if results:\n",
+ " pd.DataFrame(results).to_csv(intermediate_file, index=False)\n",
+ " \n",
+ "print(f\"\\nCompleted {len(results)} of {len(STATES)} states.\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "cell-5",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "================================================================================\n",
+ "POVERTY RATES BY STATE (2026) - 50 states completed\n",
+ "================================================================================\n",
+ "Rank State Poverty Rate Child Poverty Rate \n",
+ "--------------------------------------------------------------------------------\n",
+ "1 District of Columbia 36.8% 29.2%\n",
+ "2 New York 35.4% 28.8%\n",
+ "3 Oregon 34.3% 23.1%\n",
+ "4 Hawaii 33.4% 25.9%\n",
+ "5 Massachusetts 33.1% 23.4%\n",
+ "6 Georgia 31.9% 27.9%\n",
+ "7 Florida 31.8% 34.9%\n",
+ "8 Maryland 31.1% 25.8%\n",
+ "9 Texas 30.4% 29.2%\n",
+ "10 Mississippi 29.3% 25.5%\n",
+ "11 Delaware 29.3% 25.1%\n",
+ "12 Louisiana 29.3% 26.2%\n",
+ "13 Virginia 28.9% 21.8%\n",
+ "14 Nevada 28.5% 29.8%\n",
+ "15 Arizona 28.1% 26.8%\n",
+ "16 New Jersey 28.0% 22.3%\n",
+ "17 Alabama 27.9% 21.7%\n",
+ "18 Connecticut 27.9% 21.5%\n",
+ "19 Tennessee 27.7% 26.6%\n",
+ "20 New Mexico 27.6% 23.0%\n",
+ "21 Illinois 27.4% 20.6%\n",
+ "22 Washington 26.9% 23.2%\n",
+ "23 Rhode Island 26.8% 23.3%\n",
+ "24 North Carolina 26.7% 22.4%\n",
+ "25 Pennsylvania 26.6% 21.4%\n",
+ "26 South Carolina 26.3% 22.3%\n",
+ "27 Kentucky 26.0% 20.8%\n",
+ "28 Kansas 25.7% 18.2%\n",
+ "29 West Virginia 25.7% 22.4%\n",
+ "30 Oklahoma 25.5% 21.7%\n",
+ "31 Michigan 25.4% 20.7%\n",
+ "32 Colorado 25.3% 19.2%\n",
+ "33 Arkansas 24.8% 21.1%\n",
+ "34 Vermont 24.8% 21.3%\n",
+ "35 Maine 24.8% 18.6%\n",
+ "36 Missouri 23.7% 19.8%\n",
+ "37 Indiana 23.7% 19.8%\n",
+ "38 Ohio 22.9% 19.9%\n",
+ "39 Montana 22.5% 16.7%\n",
+ "40 Wisconsin 22.3% 16.1%\n",
+ "41 Minnesota 21.6% 14.7%\n",
+ "42 South Dakota 21.3% 19.2%\n",
+ "43 Idaho 21.1% 15.4%\n",
+ "44 Iowa 20.5% 14.8%\n",
+ "45 Utah 19.8% 14.1%\n",
+ "46 Nebraska 18.1% 13.0%\n",
+ "47 Wyoming 17.8% 16.0%\n",
+ "48 Alaska 17.1% 12.5%\n",
+ "49 North Dakota 15.4% 13.1%\n",
+ "50 New Hampshire 12.5% 13.2%\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Create DataFrame with results\n",
+ "df = pd.DataFrame(results)\n",
+ "\n",
+ "if len(df) == 0:\n",
+ " print(\"No results to display. Check for errors above.\")\n",
+ "else:\n",
+ " # Format for display\n",
+ " df[\"poverty_rate_pct\"] = df[\"poverty_rate\"] * 100\n",
+ " df[\"child_poverty_rate_pct\"] = df[\"child_poverty_rate\"] * 100\n",
+ "\n",
+ " # Sort by poverty rate (highest first)\n",
+ " df_sorted = df.sort_values(\"poverty_rate\", ascending=False).reset_index(drop=True)\n",
+ "\n",
+ " print(f\"\\n{'='*80}\")\n",
+ " print(f\"POVERTY RATES BY STATE ({ANALYSIS_YEAR}) - {len(df)} states completed\")\n",
+ " print(f\"{'='*80}\")\n",
+ " print(f\"{'Rank':<6} {'State':<25} {'Poverty Rate':<15} {'Child Poverty Rate':<20}\")\n",
+ " print(\"-\" * 80)\n",
+ " for i, row in df_sorted.iterrows():\n",
+ " print(f\"{i+1:<6} {row['state_name']:<25} {row['poverty_rate_pct']:>10.1f}% {row['child_poverty_rate_pct']:>15.1f}%\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "cell-6",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "============================================================\n",
+ "SUMMARY STATISTICS (50 states)\n",
+ "============================================================\n",
+ "\n",
+ "Overall Poverty Rate:\n",
+ " Mean: 26.0%\n",
+ " Median: 26.5%\n",
+ " Min: 12.5% (New Hampshire)\n",
+ " Max: 36.8% (District of Columbia)\n",
+ "\n",
+ "Child Poverty Rate:\n",
+ " Mean: 21.5%\n",
+ " Median: 21.6%\n",
+ " Min: 12.5% (Alaska)\n",
+ " Max: 34.9% (Florida)\n",
+ "\n",
+ "Population-Weighted Average (across 50 states):\n",
+ " Poverty rate: 28.0%\n",
+ " Child poverty rate: 23.9%\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Summary statistics\n",
+ "if len(df) > 0:\n",
+ " print(f\"\\n{'='*60}\")\n",
+ " print(f\"SUMMARY STATISTICS ({len(df)} states)\")\n",
+ " print(f\"{'='*60}\")\n",
+ "\n",
+ " print(f\"\\nOverall Poverty Rate:\")\n",
+ " print(f\" Mean: {df['poverty_rate_pct'].mean():.1f}%\")\n",
+ " print(f\" Median: {df['poverty_rate_pct'].median():.1f}%\")\n",
+ " print(f\" Min: {df['poverty_rate_pct'].min():.1f}% ({df.loc[df['poverty_rate_pct'].idxmin(), 'state_name']})\")\n",
+ " print(f\" Max: {df['poverty_rate_pct'].max():.1f}% ({df.loc[df['poverty_rate_pct'].idxmax(), 'state_name']})\")\n",
+ "\n",
+ " print(f\"\\nChild Poverty Rate:\")\n",
+ " print(f\" Mean: {df['child_poverty_rate_pct'].mean():.1f}%\")\n",
+ " print(f\" Median: {df['child_poverty_rate_pct'].median():.1f}%\")\n",
+ " print(f\" Min: {df['child_poverty_rate_pct'].min():.1f}% ({df.loc[df['child_poverty_rate_pct'].idxmin(), 'state_name']})\")\n",
+ " print(f\" Max: {df['child_poverty_rate_pct'].max():.1f}% ({df.loc[df['child_poverty_rate_pct'].idxmax(), 'state_name']})\")\n",
+ "\n",
+ " # Population-weighted national average (based on completed states)\n",
+ " national_poverty = (df['population_in_poverty'].sum() / df['total_population'].sum()) * 100\n",
+ " national_child_poverty = (df['children_in_poverty'].sum() / df['child_population'].sum()) * 100\n",
+ "\n",
+ " print(f\"\\nPopulation-Weighted Average (across {len(df)} states):\")\n",
+ " print(f\" Poverty rate: {national_poverty:.1f}%\")\n",
+ " print(f\" Child poverty rate: {national_child_poverty:.1f}%\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "cell-7",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.plotly.v1+json": {
+ "config": {
+ "plotlyServerURL": "https://plot.ly"
+ },
+ "data": [
+ {
+ "marker": {
+ "color": "#105293"
+ },
+ "name": "Overall Poverty",
+ "type": "bar",
+ "x": [
+ "DC",
+ "NY",
+ "OR",
+ "HI",
+ "MA",
+ "GA",
+ "FL",
+ "MD",
+ "TX",
+ "MS",
+ "DE",
+ "LA",
+ "VA",
+ "NV",
+ "AZ",
+ "NJ",
+ "AL",
+ "CT",
+ "TN",
+ "NM"
+ ],
+ "y": [
+ 36.79618835449219,
+ 35.37993133068085,
+ 34.250837564468384,
+ 33.40181112289429,
+ 33.08692276477814,
+ 31.93831443786621,
+ 31.843486428260803,
+ 31.147146224975586,
+ 30.435705184936523,
+ 29.32574152946472,
+ 29.313945770263672,
+ 29.294779896736145,
+ 28.87044847011566,
+ 28.496500849723816,
+ 28.14837396144867,
+ 28.00261676311493,
+ 27.947503328323364,
+ 27.862614393234253,
+ 27.675876021385193,
+ 27.640214562416077
+ ]
+ },
+ {
+ "marker": {
+ "color": "#F2994A"
+ },
+ "name": "Child Poverty",
+ "type": "bar",
+ "x": [
+ "DC",
+ "NY",
+ "OR",
+ "HI",
+ "MA",
+ "GA",
+ "FL",
+ "MD",
+ "TX",
+ "MS",
+ "DE",
+ "LA",
+ "VA",
+ "NV",
+ "AZ",
+ "NJ",
+ "AL",
+ "CT",
+ "TN",
+ "NM"
+ ],
+ "y": [
+ 29.218754172325134,
+ 28.79577875137329,
+ 23.07695299386978,
+ 25.884070992469788,
+ 23.360145092010498,
+ 27.92282998561859,
+ 34.90098416805267,
+ 25.832578539848328,
+ 29.18386459350586,
+ 25.519615411758423,
+ 25.090965628623962,
+ 26.236775517463684,
+ 21.836182475090027,
+ 29.78779375553131,
+ 26.81792378425598,
+ 22.268997132778168,
+ 21.66508287191391,
+ 21.511541306972504,
+ 26.625093817710876,
+ 22.952669858932495
+ ]
+ }
+ ],
+ "layout": {
+ "barmode": "group",
+ "legend": {
+ "x": 0.99,
+ "xanchor": "right",
+ "y": 0.99,
+ "yanchor": "top"
+ },
+ "template": {
+ "data": {
+ "bar": [
+ {
+ "error_x": {
+ "color": "#2a3f5f"
+ },
+ "error_y": {
+ "color": "#2a3f5f"
+ },
+ "marker": {
+ "line": {
+ "color": "#E5ECF6",
+ "width": 0.5
+ },
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "bar"
+ }
+ ],
+ "barpolar": [
+ {
+ "marker": {
+ "line": {
+ "color": "#E5ECF6",
+ "width": 0.5
+ },
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "barpolar"
+ }
+ ],
+ "carpet": [
+ {
+ "aaxis": {
+ "endlinecolor": "#2a3f5f",
+ "gridcolor": "white",
+ "linecolor": "white",
+ "minorgridcolor": "white",
+ "startlinecolor": "#2a3f5f"
+ },
+ "baxis": {
+ "endlinecolor": "#2a3f5f",
+ "gridcolor": "white",
+ "linecolor": "white",
+ "minorgridcolor": "white",
+ "startlinecolor": "#2a3f5f"
+ },
+ "type": "carpet"
+ }
+ ],
+ "choropleth": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "type": "choropleth"
+ }
+ ],
+ "contour": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "contour"
+ }
+ ],
+ "contourcarpet": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "type": "contourcarpet"
+ }
+ ],
+ "heatmap": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "heatmap"
+ }
+ ],
+ "heatmapgl": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "heatmapgl"
+ }
+ ],
+ "histogram": [
+ {
+ "marker": {
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "histogram"
+ }
+ ],
+ "histogram2d": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "histogram2d"
+ }
+ ],
+ "histogram2dcontour": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "histogram2dcontour"
+ }
+ ],
+ "mesh3d": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "type": "mesh3d"
+ }
+ ],
+ "parcoords": [
+ {
+ "line": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "parcoords"
+ }
+ ],
+ "pie": [
+ {
+ "automargin": true,
+ "type": "pie"
+ }
+ ],
+ "scatter": [
+ {
+ "fillpattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ },
+ "type": "scatter"
+ }
+ ],
+ "scatter3d": [
+ {
+ "line": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatter3d"
+ }
+ ],
+ "scattercarpet": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattercarpet"
+ }
+ ],
+ "scattergeo": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattergeo"
+ }
+ ],
+ "scattergl": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattergl"
+ }
+ ],
+ "scattermapbox": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattermapbox"
+ }
+ ],
+ "scatterpolar": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatterpolar"
+ }
+ ],
+ "scatterpolargl": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatterpolargl"
+ }
+ ],
+ "scatterternary": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatterternary"
+ }
+ ],
+ "surface": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "surface"
+ }
+ ],
+ "table": [
+ {
+ "cells": {
+ "fill": {
+ "color": "#EBF0F8"
+ },
+ "line": {
+ "color": "white"
+ }
+ },
+ "header": {
+ "fill": {
+ "color": "#C8D4E3"
+ },
+ "line": {
+ "color": "white"
+ }
+ },
+ "type": "table"
+ }
+ ]
+ },
+ "layout": {
+ "annotationdefaults": {
+ "arrowcolor": "#2a3f5f",
+ "arrowhead": 0,
+ "arrowwidth": 1
+ },
+ "autotypenumbers": "strict",
+ "coloraxis": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "colorscale": {
+ "diverging": [
+ [
+ 0,
+ "#8e0152"
+ ],
+ [
+ 0.1,
+ "#c51b7d"
+ ],
+ [
+ 0.2,
+ "#de77ae"
+ ],
+ [
+ 0.3,
+ "#f1b6da"
+ ],
+ [
+ 0.4,
+ "#fde0ef"
+ ],
+ [
+ 0.5,
+ "#f7f7f7"
+ ],
+ [
+ 0.6,
+ "#e6f5d0"
+ ],
+ [
+ 0.7,
+ "#b8e186"
+ ],
+ [
+ 0.8,
+ "#7fbc41"
+ ],
+ [
+ 0.9,
+ "#4d9221"
+ ],
+ [
+ 1,
+ "#276419"
+ ]
+ ],
+ "sequential": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "sequentialminus": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ]
+ },
+ "colorway": [
+ "#636efa",
+ "#EF553B",
+ "#00cc96",
+ "#ab63fa",
+ "#FFA15A",
+ "#19d3f3",
+ "#FF6692",
+ "#B6E880",
+ "#FF97FF",
+ "#FECB52"
+ ],
+ "font": {
+ "color": "#2a3f5f"
+ },
+ "geo": {
+ "bgcolor": "white",
+ "lakecolor": "white",
+ "landcolor": "#E5ECF6",
+ "showlakes": true,
+ "showland": true,
+ "subunitcolor": "white"
+ },
+ "hoverlabel": {
+ "align": "left"
+ },
+ "hovermode": "closest",
+ "mapbox": {
+ "style": "light"
+ },
+ "paper_bgcolor": "white",
+ "plot_bgcolor": "#E5ECF6",
+ "polar": {
+ "angularaxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ },
+ "bgcolor": "#E5ECF6",
+ "radialaxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ }
+ },
+ "scene": {
+ "xaxis": {
+ "backgroundcolor": "#E5ECF6",
+ "gridcolor": "white",
+ "gridwidth": 2,
+ "linecolor": "white",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "white"
+ },
+ "yaxis": {
+ "backgroundcolor": "#E5ECF6",
+ "gridcolor": "white",
+ "gridwidth": 2,
+ "linecolor": "white",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "white"
+ },
+ "zaxis": {
+ "backgroundcolor": "#E5ECF6",
+ "gridcolor": "white",
+ "gridwidth": 2,
+ "linecolor": "white",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "white"
+ }
+ },
+ "shapedefaults": {
+ "line": {
+ "color": "#2a3f5f"
+ }
+ },
+ "ternary": {
+ "aaxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ },
+ "baxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ },
+ "bgcolor": "#E5ECF6",
+ "caxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ }
+ },
+ "title": {
+ "x": 0.05
+ },
+ "xaxis": {
+ "automargin": true,
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": "",
+ "title": {
+ "standoff": 15
+ },
+ "zerolinecolor": "white",
+ "zerolinewidth": 2
+ },
+ "yaxis": {
+ "automargin": true,
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": "",
+ "title": {
+ "standoff": 15
+ },
+ "zerolinecolor": "white",
+ "zerolinewidth": 2
+ }
+ }
+ },
+ "title": {
+ "text": "Top 20 States by Poverty Rate (2026)"
+ },
+ "xaxis": {
+ "title": {
+ "text": "State"
+ }
+ },
+ "yaxis": {
+ "title": {
+ "text": "Poverty Rate (%)"
+ }
+ }
+ }
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "# Visualization: Bar chart of poverty rates\n",
+ "df_plot = df_sorted.head(20) # Top 20 highest poverty\n",
+ "\n",
+ "fig = go.Figure()\n",
+ "\n",
+ "fig.add_trace(go.Bar(\n",
+ " name=\"Overall Poverty\",\n",
+ " x=df_plot[\"state\"],\n",
+ " y=df_plot[\"poverty_rate_pct\"],\n",
+ " marker_color=\"#105293\",\n",
+ "))\n",
+ "\n",
+ "fig.add_trace(go.Bar(\n",
+ " name=\"Child Poverty\",\n",
+ " x=df_plot[\"state\"],\n",
+ " y=df_plot[\"child_poverty_rate_pct\"],\n",
+ " marker_color=\"#F2994A\",\n",
+ "))\n",
+ "\n",
+ "fig.update_layout(\n",
+ " title=f\"Top 20 States by Poverty Rate ({ANALYSIS_YEAR})\",\n",
+ " xaxis_title=\"State\",\n",
+ " yaxis_title=\"Poverty Rate (%)\",\n",
+ " barmode=\"group\",\n",
+ " legend=dict(yanchor=\"top\", y=0.99, xanchor=\"right\", x=0.99),\n",
+ ")\n",
+ "\n",
+ "fig.show()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "id": "cell-8",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.plotly.v1+json": {
+ "config": {
+ "plotlyServerURL": "https://plot.ly"
+ },
+ "data": [
+ {
+ "coloraxis": "coloraxis",
+ "customdata": [
+ [
+ 17.832069098949432,
+ 15.99229872226715,
+ "WY"
+ ],
+ [
+ 24.789130687713623,
+ 21.34946882724762,
+ "VT"
+ ],
+ [
+ 36.79618835449219,
+ 29.218754172325134,
+ "DC"
+ ],
+ [
+ 17.061617970466614,
+ 12.466702610254288,
+ "AK"
+ ],
+ [
+ 15.398578345775604,
+ 13.072727620601654,
+ "ND"
+ ],
+ [
+ 21.27697467803955,
+ 19.209976494312286,
+ "SD"
+ ],
+ [
+ 29.313945770263672,
+ 25.090965628623962,
+ "DE"
+ ],
+ [
+ 26.793450117111206,
+ 23.320218920707703,
+ "RI"
+ ],
+ [
+ 22.4557027220726,
+ 16.7365163564682,
+ "MT"
+ ],
+ [
+ 24.7724786400795,
+ 18.56364905834198,
+ "ME"
+ ],
+ [
+ 12.45487630367279,
+ 13.20013552904129,
+ "NH"
+ ],
+ [
+ 33.40181112289429,
+ 25.884070992469788,
+ "HI"
+ ],
+ [
+ 25.659838318824768,
+ 22.397008538246155,
+ "WV"
+ ],
+ [
+ 21.114841103553772,
+ 15.448057651519775,
+ "ID"
+ ],
+ [
+ 18.14100295305252,
+ 13.015952706336975,
+ "NE"
+ ],
+ [
+ 27.640214562416077,
+ 22.952669858932495,
+ "NM"
+ ],
+ [
+ 25.662240386009216,
+ 18.242594599723816,
+ "KS"
+ ],
+ [
+ 29.32574152946472,
+ 25.519615411758423,
+ "MS"
+ ],
+ [
+ 24.823197722434998,
+ 21.12293243408203,
+ "AR"
+ ],
+ [
+ 28.496500849723816,
+ 29.78779375553131,
+ "NV"
+ ],
+ [
+ 20.54479867219925,
+ 14.835599064826965,
+ "IA"
+ ],
+ [
+ 19.75550800561905,
+ 14.13036435842514,
+ "UT"
+ ],
+ [
+ 27.862614393234253,
+ 21.511541306972504,
+ "CT"
+ ],
+ [
+ 25.476279854774475,
+ 21.69877141714096,
+ "OK"
+ ],
+ [
+ 34.250837564468384,
+ 23.07695299386978,
+ "OR"
+ ],
+ [
+ 26.028868556022644,
+ 20.846913754940033,
+ "KY"
+ ],
+ [
+ 29.294779896736145,
+ 26.236775517463684,
+ "LA"
+ ],
+ [
+ 27.947503328323364,
+ 21.66508287191391,
+ "AL"
+ ],
+ [
+ 26.34265422821045,
+ 22.25310057401657,
+ "SC"
+ ],
+ [
+ 21.6079980134964,
+ 14.657293260097504,
+ "MN"
+ ],
+ [
+ 25.348225235939026,
+ 19.19110417366028,
+ "CO"
+ ],
+ [
+ 22.315840423107147,
+ 16.105875372886658,
+ "WI"
+ ],
+ [
+ 31.147146224975586,
+ 25.832578539848328,
+ "MD"
+ ],
+ [
+ 23.717473447322845,
+ 19.812971353530884,
+ "MO"
+ ],
+ [
+ 27.675876021385193,
+ 26.625093817710876,
+ "TN"
+ ],
+ [
+ 28.14837396144867,
+ 26.81792378425598,
+ "AZ"
+ ],
+ [
+ 23.684823513031006,
+ 19.758273661136627,
+ "IN"
+ ],
+ [
+ 33.08692276477814,
+ 23.360145092010498,
+ "MA"
+ ],
+ [
+ 26.893332600593567,
+ 23.234081268310547,
+ "WA"
+ ],
+ [
+ 28.87044847011566,
+ 21.836182475090027,
+ "VA"
+ ],
+ [
+ 28.00261676311493,
+ 22.268997132778168,
+ "NJ"
+ ],
+ [
+ 25.444668531417847,
+ 20.677094161510468,
+ "MI"
+ ],
+ [
+ 26.67444348335266,
+ 22.418732941150665,
+ "NC"
+ ],
+ [
+ 31.93831443786621,
+ 27.92282998561859,
+ "GA"
+ ],
+ [
+ 22.865432500839233,
+ 19.851620495319366,
+ "OH"
+ ],
+ [
+ 27.36758291721344,
+ 20.648689568042755,
+ "IL"
+ ],
+ [
+ 26.59434676170349,
+ 21.44276648759842,
+ "PA"
+ ],
+ [
+ 35.37993133068085,
+ 28.79577875137329,
+ "NY"
+ ],
+ [
+ 31.843486428260803,
+ 34.90098416805267,
+ "FL"
+ ],
+ [
+ 30.435705184936523,
+ 29.18386459350586,
+ "TX"
+ ]
+ ],
+ "geo": "geo",
+ "hovertemplate": "%{hovertext}
Poverty Rate (%)=%{z:.1f}
child_poverty_rate_pct=%{customdata[1]:.1f}
poverty_rate_pct=%{customdata[0]:.1f}
Child Poverty Rate (%)=%{z:.1f}
| \n", + " | State Code | \n", + "State Name | \n", + "Poverty Rate (%) | \n", + "Child Poverty Rate (%) | \n", + "Total Population | \n", + "Child Population | \n", + "Population in Poverty | \n", + "Children in Poverty | \n", + "
|---|---|---|---|---|---|---|---|---|
| 2 | \n", + "DC | \n", + "District of Columbia | \n", + "36.8 | \n", + "29.2 | \n", + "688,772 | \n", + "144,009 | \n", + "253,442 | \n", + "42,078 | \n", + "
| 47 | \n", + "NY | \n", + "New York | \n", + "35.4 | \n", + "28.8 | \n", + "19,979,982 | \n", + "4,335,587 | \n", + "7,068,904 | \n", + "1,248,466 | \n", + "
| 24 | \n", + "OR | \n", + "Oregon | \n", + "34.3 | \n", + "23.1 | \n", + "4,285,052 | \n", + "897,387 | \n", + "1,467,666 | \n", + "207,090 | \n", + "
| 11 | \n", + "HI | \n", + "Hawaii | \n", + "33.4 | \n", + "25.9 | \n", + "1,451,218 | \n", + "315,645 | \n", + "484,733 | \n", + "81,702 | \n", + "
| 37 | \n", + "MA | \n", + "Massachusetts | \n", + "33.1 | \n", + "23.4 | \n", + "7,142,086 | \n", + "1,502,289 | \n", + "2,363,096 | \n", + "350,937 | \n", + "
| 43 | \n", + "GA | \n", + "Georgia | \n", + "31.9 | \n", + "27.9 | \n", + "11,219,642 | \n", + "2,723,662 | \n", + "3,583,364 | \n", + "760,523 | \n", + "
| 48 | \n", + "FL | \n", + "Florida | \n", + "31.8 | \n", + "34.9 | \n", + "23,400,412 | \n", + "4,808,358 | \n", + "7,451,507 | \n", + "1,678,164 | \n", + "
| 32 | \n", + "MD | \n", + "Maryland | \n", + "31.1 | \n", + "25.8 | \n", + "6,271,177 | \n", + "1,467,694 | \n", + "1,953,293 | \n", + "379,143 | \n", + "
| 49 | \n", + "TX | \n", + "Texas | \n", + "30.4 | \n", + "29.2 | \n", + "31,307,682 | \n", + "8,122,860 | \n", + "9,528,714 | \n", + "2,370,564 | \n", + "
| 17 | \n", + "MS | \n", + "Mississippi | \n", + "29.3 | \n", + "25.5 | \n", + "2,976,668 | \n", + "726,285 | \n", + "872,930 | \n", + "185,345 | \n", + "
| 6 | \n", + "DE | \n", + "Delaware | \n", + "29.3 | \n", + "25.1 | \n", + "1,039,111 | \n", + "231,777 | \n", + "304,604 | \n", + "58,155 | \n", + "
| 26 | \n", + "LA | \n", + "Louisiana | \n", + "29.3 | \n", + "26.2 | \n", + "4,624,575 | \n", + "1,138,450 | \n", + "1,354,759 | \n", + "298,693 | \n", + "
| 39 | \n", + "VA | \n", + "Virginia | \n", + "28.9 | \n", + "21.8 | \n", + "8,808,460 | \n", + "2,027,262 | \n", + "2,543,042 | \n", + "442,677 | \n", + "
| 19 | \n", + "NV | \n", + "Nevada | \n", + "28.5 | \n", + "29.8 | \n", + "3,270,766 | \n", + "726,141 | \n", + "932,054 | \n", + "216,301 | \n", + "
| 35 | \n", + "AZ | \n", + "Arizona | \n", + "28.1 | \n", + "26.8 | \n", + "7,569,420 | \n", + "1,695,481 | \n", + "2,130,669 | \n", + "454,693 | \n", + "
| 40 | \n", + "NJ | \n", + "New Jersey | \n", + "28.0 | \n", + "22.3 | \n", + "9,539,998 | \n", + "2,181,264 | \n", + "2,671,449 | \n", + "485,746 | \n", + "
| 27 | \n", + "AL | \n", + "Alabama | \n", + "27.9 | \n", + "21.7 | \n", + "5,186,474 | \n", + "1,229,586 | \n", + "1,449,490 | \n", + "266,391 | \n", + "
| 22 | \n", + "CT | \n", + "Connecticut | \n", + "27.9 | \n", + "21.5 | \n", + "3,716,337 | \n", + "787,130 | \n", + "1,035,469 | \n", + "169,324 | \n", + "
| 34 | \n", + "TN | \n", + "Tennessee | \n", + "27.7 | \n", + "26.6 | \n", + "7,268,876 | \n", + "1,682,223 | \n", + "2,011,725 | \n", + "447,893 | \n", + "
| 15 | \n", + "NM | \n", + "New Mexico | \n", + "27.6 | \n", + "23.0 | \n", + "2,151,059 | \n", + "475,879 | \n", + "594,557 | \n", + "109,227 | \n", + "
| 45 | \n", + "IL | \n", + "Illinois | \n", + "27.4 | \n", + "20.6 | \n", + "12,761,942 | \n", + "2,898,220 | \n", + "3,492,635 | \n", + "598,444 | \n", + "
| 38 | \n", + "WA | \n", + "Washington | \n", + "26.9 | \n", + "23.2 | \n", + "7,993,409 | \n", + "1,765,756 | \n", + "2,149,694 | \n", + "410,257 | \n", + "
| 7 | \n", + "RI | \n", + "Rhode Island | \n", + "26.8 | \n", + "23.3 | \n", + "1,128,504 | \n", + "223,834 | \n", + "302,365 | \n", + "52,198 | \n", + "
| 42 | \n", + "NC | \n", + "North Carolina | \n", + "26.7 | \n", + "22.4 | \n", + "11,035,400 | \n", + "2,518,402 | \n", + "2,943,632 | \n", + "564,594 | \n", + "
| 46 | \n", + "PA | \n", + "Pennsylvania | \n", + "26.6 | \n", + "21.4 | \n", + "13,160,592 | \n", + "2,868,244 | \n", + "3,499,974 | \n", + "615,031 | \n", + "
| 28 | \n", + "SC | \n", + "South Carolina | \n", + "26.3 | \n", + "22.3 | \n", + "5,504,352 | \n", + "1,240,536 | \n", + "1,449,993 | \n", + "276,058 | \n", + "
| 25 | \n", + "KY | \n", + "Kentucky | \n", + "26.0 | \n", + "20.8 | \n", + "4,606,871 | \n", + "1,092,900 | \n", + "1,199,116 | \n", + "227,836 | \n", + "
| 16 | \n", + "KS | \n", + "Kansas | \n", + "25.7 | \n", + "18.2 | \n", + "3,012,524 | \n", + "747,167 | \n", + "773,081 | \n", + "136,303 | \n", + "
| 12 | \n", + "WV | \n", + "West Virginia | \n", + "25.7 | \n", + "22.4 | \n", + "1,759,224 | \n", + "376,035 | \n", + "451,414 | \n", + "84,221 | \n", + "
| 23 | \n", + "OK | \n", + "Oklahoma | \n", + "25.5 | \n", + "21.7 | \n", + "4,082,824 | \n", + "1,025,540 | \n", + "1,040,152 | \n", + "222,530 | \n", + "
| 41 | \n", + "MI | \n", + "Michigan | \n", + "25.4 | \n", + "20.7 | \n", + "10,167,090 | \n", + "2,270,740 | \n", + "2,586,982 | \n", + "469,523 | \n", + "
| 30 | \n", + "CO | \n", + "Colorado | \n", + "25.3 | \n", + "19.2 | \n", + "5,949,264 | \n", + "1,300,790 | \n", + "1,508,033 | \n", + "249,636 | \n", + "
| 18 | \n", + "AR | \n", + "Arkansas | \n", + "24.8 | \n", + "21.1 | \n", + "3,098,966 | \n", + "750,715 | \n", + "769,262 | \n", + "158,573 | \n", + "
| 1 | \n", + "VT | \n", + "Vermont | \n", + "24.8 | \n", + "21.3 | \n", + "654,492 | \n", + "123,710 | \n", + "162,243 | \n", + "26,411 | \n", + "
| 9 | \n", + "ME | \n", + "Maine | \n", + "24.8 | \n", + "18.6 | \n", + "1,415,236 | \n", + "266,199 | \n", + "350,589 | \n", + "49,416 | \n", + "
| 33 | \n", + "MO | \n", + "Missouri | \n", + "23.7 | \n", + "19.8 | \n", + "6,281,968 | \n", + "1,463,929 | \n", + "1,489,924 | \n", + "290,048 | \n", + "
| 36 | \n", + "IN | \n", + "Indiana | \n", + "23.7 | \n", + "19.8 | \n", + "6,999,368 | \n", + "1,704,800 | \n", + "1,657,788 | \n", + "336,839 | \n", + "
| 44 | \n", + "OH | \n", + "Ohio | \n", + "22.9 | \n", + "19.9 | \n", + "11,972,272 | \n", + "2,754,182 | \n", + "2,737,512 | \n", + "546,750 | \n", + "
| 8 | \n", + "MT | \n", + "Montana | \n", + "22.5 | \n", + "16.7 | \n", + "1,149,116 | \n", + "246,726 | \n", + "258,042 | \n", + "41,293 | \n", + "
| 31 | \n", + "WI | \n", + "Wisconsin | \n", + "22.3 | \n", + "16.1 | \n", + "6,003,145 | \n", + "1,327,217 | \n", + "1,339,652 | \n", + "213,760 | \n", + "
| 29 | \n", + "MN | \n", + "Minnesota | \n", + "21.6 | \n", + "14.7 | \n", + "5,813,433 | \n", + "1,380,610 | \n", + "1,256,166 | \n", + "202,360 | \n", + "
| 5 | \n", + "SD | \n", + "South Dakota | \n", + "21.3 | \n", + "19.2 | \n", + "933,974 | \n", + "233,976 | \n", + "198,721 | \n", + "44,947 | \n", + "
| 13 | \n", + "ID | \n", + "Idaho | \n", + "21.1 | \n", + "15.4 | \n", + "1,977,166 | \n", + "498,487 | \n", + "417,476 | \n", + "77,006 | \n", + "
| 20 | \n", + "IA | \n", + "Iowa | \n", + "20.5 | \n", + "14.8 | \n", + "3,244,085 | \n", + "782,335 | \n", + "666,491 | \n", + "116,064 | \n", + "
| 21 | \n", + "UT | \n", + "Utah | \n", + "19.8 | \n", + "14.1 | \n", + "3,455,203 | \n", + "972,374 | \n", + "682,593 | \n", + "137,400 | \n", + "
| 14 | \n", + "NE | \n", + "Nebraska | \n", + "18.1 | \n", + "13.0 | \n", + "2,022,241 | \n", + "508,053 | \n", + "366,855 | \n", + "66,128 | \n", + "
| 0 | \n", + "WY | \n", + "Wyoming | \n", + "17.8 | \n", + "16.0 | \n", + "599,583 | \n", + "133,008 | \n", + "106,918 | \n", + "21,271 | \n", + "
| 3 | \n", + "AK | \n", + "Alaska | \n", + "17.1 | \n", + "12.5 | \n", + "740,242 | \n", + "178,709 | \n", + "126,297 | \n", + "22,279 | \n", + "
| 4 | \n", + "ND | \n", + "North Dakota | \n", + "15.4 | \n", + "13.1 | \n", + "793,403 | \n", + "190,323 | \n", + "122,173 | \n", + "24,880 | \n", + "
| 10 | \n", + "NH | \n", + "New Hampshire | \n", + "12.5 | \n", + "13.2 | \n", + "1,425,187 | \n", + "263,602 | \n", + "177,505 | \n", + "34,796 | \n", + "