From 912df7853412465cd5172e128d5318cab5b62e11 Mon Sep 17 00:00:00 2001 From: David Trimmer Date: Mon, 23 Mar 2026 11:57:03 -0400 Subject: [PATCH 1/3] Add notebook for state poverty and child poverty rate calculations Implements #127: Calculate SPM poverty and child poverty rates for all 50 US states plus DC using PolicyEngine microsimulation with state-specific datasets. Features: - Downloads state datasets from HuggingFace - Calculates person_in_poverty rates (SPM definition) - Child poverty filtering (age < 18) - Summary statistics and national averages - Choropleth map visualizations - CSV export of results Co-Authored-By: Claude Opus 4.5 --- us/poverty/state_poverty_rates.ipynb | 369 +++++++++++++++++++++++++++ 1 file changed, 369 insertions(+) create mode 100644 us/poverty/state_poverty_rates.ipynb diff --git a/us/poverty/state_poverty_rates.ipynb b/us/poverty/state_poverty_rates.ipynb new file mode 100644 index 0000000..6923f17 --- /dev/null +++ b/us/poverty/state_poverty_rates.ipynb @@ -0,0 +1,369 @@ +{ + "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": null, + "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" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cell-2", + "metadata": {}, + "outputs": [], + "source": [ + "# Configuration\n", + "ANALYSIS_YEAR = 2026\n", + "\n", + "# All 50 states + DC\n", + "STATES = [\n", + " \"AL\", \"AK\", \"AZ\", \"AR\", \"CA\", \"CO\", \"CT\", \"DE\", \"FL\", \"GA\",\n", + " \"HI\", \"ID\", \"IL\", \"IN\", \"IA\", \"KS\", \"KY\", \"LA\", \"ME\", \"MD\",\n", + " \"MA\", \"MI\", \"MN\", \"MS\", \"MO\", \"MT\", \"NE\", \"NV\", \"NH\", \"NJ\",\n", + " \"NM\", \"NY\", \"NC\", \"ND\", \"OH\", \"OK\", \"OR\", \"PA\", \"RI\", \"SC\",\n", + " \"SD\", \"TN\", \"TX\", \"UT\", \"VT\", \"VA\", \"WA\", \"WV\", \"WI\", \"WY\",\n", + " \"DC\"\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": null, + "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", + " # Get state dataset and run simulation\n", + " dataset_path = get_state_dataset(state)\n", + " sim = Microsimulation(dataset=dataset_path)\n", + " \n", + " # Get person-level poverty status (MicroSeries with weights)\n", + " poverty = sim.calculate(\"person_in_poverty\", year)\n", + " age = sim.calculate(\"age\", year)\n", + " person_weight = sim.calculate(\"person_weight\", year)\n", + " \n", + " # Overall poverty rate (weighted mean)\n", + " poverty_rate = float(poverty.mean())\n", + " \n", + " # Child poverty rate (age < 18)\n", + " child_mask = age < 18\n", + " \n", + " # For child poverty, we need to manually calculate weighted mean\n", + " # since MicroSeries slicing may lose weights\n", + " poverty_arr = np.array(poverty.values).astype(float)\n", + " weight_arr = np.array(person_weight.values)\n", + " age_arr = np.array(age.values)\n", + " \n", + " child_mask_arr = age_arr < 18\n", + " \n", + " if np.sum(weight_arr[child_mask_arr]) > 0:\n", + " child_poverty_rate = float(\n", + " np.average(poverty_arr[child_mask_arr], weights=weight_arr[child_mask_arr])\n", + " )\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_arr].sum())\n", + " population_in_poverty = float((poverty_arr * weight_arr).sum())\n", + " children_in_poverty = float((poverty_arr[child_mask_arr] * weight_arr[child_mask_arr]).sum())\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": null, + "id": "cell-4", + "metadata": {}, + "outputs": [], + "source": [ + "# Calculate poverty rates for all states\n", + "print(f\"Calculating poverty rates for {len(STATES)} jurisdictions...\\n\")\n", + "\n", + "results = []\n", + "for i, state in enumerate(STATES):\n", + " print(f\"[{i+1}/{len(STATES)}] Processing {STATE_NAMES[state]}...\")\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 poverty: {state_results['child_poverty_rate']:.1%}\")\n", + " except Exception as e:\n", + " print(f\" ERROR: {e}\")\n", + "\n", + "print(f\"\\nCompleted {len(results)} states.\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cell-5", + "metadata": {}, + "outputs": [], + "source": [ + "# Create DataFrame with results\n", + "df = pd.DataFrame(results)\n", + "\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})\")\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": null, + "id": "cell-6", + "metadata": {}, + "outputs": [], + "source": [ + "# Summary statistics\n", + "print(f\"\\n{'='*60}\")\n", + "print(\"SUMMARY STATISTICS\")\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\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\"\\nNational (Population-Weighted):\")\n", + "print(f\" Poverty rate: {national_poverty:.1f}%\")\n", + "print(f\" Child poverty rate: {national_child_poverty:.1f}%\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cell-7", + "metadata": {}, + "outputs": [], + "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": null, + "id": "cell-8", + "metadata": {}, + "outputs": [], + "source": [ + "# Visualization: Choropleth map of poverty rates\n", + "fig_map = px.choropleth(\n", + " df,\n", + " locations=\"state\",\n", + " locationmode=\"USA-states\",\n", + " color=\"poverty_rate_pct\",\n", + " scope=\"usa\",\n", + " color_continuous_scale=\"Reds\",\n", + " labels={\"poverty_rate_pct\": \"Poverty Rate (%)\"},\n", + " title=f\"SPM Poverty Rate by State ({ANALYSIS_YEAR})\",\n", + " hover_name=\"state_name\",\n", + " hover_data={\"poverty_rate_pct\": \":.1f\", \"child_poverty_rate_pct\": \":.1f\", \"state\": False},\n", + ")\n", + "\n", + "fig_map.update_layout(\n", + " geo=dict(bgcolor=\"rgba(0,0,0,0)\"),\n", + ")\n", + "\n", + "fig_map.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cell-9", + "metadata": {}, + "outputs": [], + "source": [ + "# Visualization: Child poverty choropleth\n", + "fig_child_map = px.choropleth(\n", + " df,\n", + " locations=\"state\",\n", + " locationmode=\"USA-states\",\n", + " color=\"child_poverty_rate_pct\",\n", + " scope=\"usa\",\n", + " color_continuous_scale=\"Oranges\",\n", + " labels={\"child_poverty_rate_pct\": \"Child Poverty Rate (%)\"},\n", + " title=f\"SPM Child Poverty Rate by State ({ANALYSIS_YEAR})\",\n", + " hover_name=\"state_name\",\n", + " hover_data={\"poverty_rate_pct\": \":.1f\", \"child_poverty_rate_pct\": \":.1f\", \"state\": False},\n", + ")\n", + "\n", + "fig_child_map.update_layout(\n", + " geo=dict(bgcolor=\"rgba(0,0,0,0)\"),\n", + ")\n", + "\n", + "fig_child_map.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cell-10", + "metadata": {}, + "outputs": [], + "source": [ + "# Export to CSV\n", + "output_df = df[[\"state\", \"state_name\", \"poverty_rate_pct\", \"child_poverty_rate_pct\", \n", + " \"total_population\", \"child_population\", \"population_in_poverty\", \"children_in_poverty\"]].copy()\n", + "output_df.columns = [\"State Code\", \"State Name\", \"Poverty Rate (%)\", \"Child Poverty Rate (%)\",\n", + " \"Total Population\", \"Child Population\", \"Population in Poverty\", \"Children in Poverty\"]\n", + "output_df = output_df.sort_values(\"Poverty Rate (%)\", ascending=False)\n", + "\n", + "output_df.to_csv(\"state_poverty_rates.csv\", index=False)\n", + "print(f\"Results saved to state_poverty_rates.csv\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cell-11", + "metadata": {}, + "outputs": [], + "source": [ + "# Display full table\n", + "display_df = output_df.copy()\n", + "display_df[\"Poverty Rate (%)\"] = display_df[\"Poverty Rate (%)\"].round(1)\n", + "display_df[\"Child Poverty Rate (%)\"] = display_df[\"Child Poverty Rate (%)\"].round(1)\n", + "display_df[\"Total Population\"] = display_df[\"Total Population\"].apply(lambda x: f\"{x:,.0f}\")\n", + "display_df[\"Child Population\"] = display_df[\"Child Population\"].apply(lambda x: f\"{x:,.0f}\")\n", + "display_df[\"Population in Poverty\"] = display_df[\"Population in Poverty\"].apply(lambda x: f\"{x:,.0f}\")\n", + "display_df[\"Children in Poverty\"] = display_df[\"Children in Poverty\"].apply(lambda x: f\"{x:,.0f}\")\n", + "display_df" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "name": "python", + "version": "3.10.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From d8a58532182a791cb02f9ab04cef1bd1a20263f2 Mon Sep 17 00:00:00 2001 From: David Trimmer Date: Tue, 24 Mar 2026 12:56:45 -0400 Subject: [PATCH 2/3] Optimize state poverty rates notebook for memory efficiency - Add garbage collection after each state to prevent memory buildup - Use float32 dtype to reduce memory footprint by 50% - Reorder states by population (smallest first) to reduce early memory pressure - Add checkpoint/resume functionality to recover from kernel crashes - Include year in output CSV filename for clarity Co-Authored-By: Claude Opus 4.5 --- us/poverty/state_poverty_rates.ipynb | 5858 +++++++++++++++++++++++++- 1 file changed, 5771 insertions(+), 87 deletions(-) diff --git a/us/poverty/state_poverty_rates.ipynb b/us/poverty/state_poverty_rates.ipynb index 6923f17..edf2f93 100644 --- a/us/poverty/state_poverty_rates.ipynb +++ b/us/poverty/state_poverty_rates.ipynb @@ -17,7 +17,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "cell-1", "metadata": {}, "outputs": [], @@ -27,12 +27,13 @@ "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" + "import plotly.graph_objects as go\n", + "import gc # For memory management" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "cell-2", "metadata": {}, "outputs": [], @@ -40,14 +41,15 @@ "# Configuration\n", "ANALYSIS_YEAR = 2026\n", "\n", - "# All 50 states + DC\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", - " \"AL\", \"AK\", \"AZ\", \"AR\", \"CA\", \"CO\", \"CT\", \"DE\", \"FL\", \"GA\",\n", - " \"HI\", \"ID\", \"IL\", \"IN\", \"IA\", \"KS\", \"KY\", \"LA\", \"ME\", \"MD\",\n", - " \"MA\", \"MI\", \"MN\", \"MS\", \"MO\", \"MT\", \"NE\", \"NV\", \"NH\", \"NJ\",\n", - " \"NM\", \"NY\", \"NC\", \"ND\", \"OH\", \"OK\", \"OR\", \"PA\", \"RI\", \"SC\",\n", - " \"SD\", \"TN\", \"TX\", \"UT\", \"VT\", \"VA\", \"WA\", \"WV\", \"WI\", \"WY\",\n", - " \"DC\"\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", @@ -70,7 +72,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "cell-3", "metadata": {}, "outputs": [], @@ -92,42 +94,42 @@ " \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", - " # Get person-level poverty status (MicroSeries with weights)\n", - " poverty = sim.calculate(\"person_in_poverty\", year)\n", - " age = sim.calculate(\"age\", year)\n", - " person_weight = sim.calculate(\"person_weight\", year)\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(poverty.mean())\n", + " poverty_rate = float(np.average(poverty_arr, weights=weight_arr))\n", " \n", " # Child poverty rate (age < 18)\n", - " child_mask = age < 18\n", - " \n", - " # For child poverty, we need to manually calculate weighted mean\n", - " # since MicroSeries slicing may lose weights\n", - " poverty_arr = np.array(poverty.values).astype(float)\n", - " weight_arr = np.array(person_weight.values)\n", - " age_arr = np.array(age.values)\n", + " child_mask = age_arr < 18\n", " \n", - " child_mask_arr = age_arr < 18\n", - " \n", - " if np.sum(weight_arr[child_mask_arr]) > 0:\n", - " child_poverty_rate = float(\n", - " np.average(poverty_arr[child_mask_arr], weights=weight_arr[child_mask_arr])\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_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_arr] * weight_arr[child_mask_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", @@ -143,92 +145,2423 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "cell-4", "metadata": {}, - "outputs": [], + "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:0010.1f}% {row['child_poverty_rate_pct']:>15.1f}%\")" + " 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": null, + "execution_count": 6, "id": "cell-6", "metadata": {}, - "outputs": [], + "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", - "print(f\"\\n{'='*60}\")\n", - "print(\"SUMMARY STATISTICS\")\n", - "print(f\"{'='*60}\")\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", + " 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", + " 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\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", + " # 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\"\\nNational (Population-Weighted):\")\n", - "print(f\" Poverty rate: {national_poverty:.1f}%\")\n", - "print(f\" Child poverty rate: {national_child_poverty:.1f}%\")" + " 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": null, + "execution_count": 7, "id": "cell-7", "metadata": {}, - "outputs": [], + "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", @@ -262,10 +2595,1324 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "cell-8", "metadata": {}, - "outputs": [], + "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}", + "hovertext": [ + "Wyoming", + "Vermont", + "District of Columbia", + "Alaska", + "North Dakota", + "South Dakota", + "Delaware", + "Rhode Island", + "Montana", + "Maine", + "New Hampshire", + "Hawaii", + "West Virginia", + "Idaho", + "Nebraska", + "New Mexico", + "Kansas", + "Mississippi", + "Arkansas", + "Nevada", + "Iowa", + "Utah", + "Connecticut", + "Oklahoma", + "Oregon", + "Kentucky", + "Louisiana", + "Alabama", + "South Carolina", + "Minnesota", + "Colorado", + "Wisconsin", + "Maryland", + "Missouri", + "Tennessee", + "Arizona", + "Indiana", + "Massachusetts", + "Washington", + "Virginia", + "New Jersey", + "Michigan", + "North Carolina", + "Georgia", + "Ohio", + "Illinois", + "Pennsylvania", + "New York", + "Florida", + "Texas" + ], + "locationmode": "USA-states", + "locations": [ + "WY", + "VT", + "DC", + "AK", + "ND", + "SD", + "DE", + "RI", + "MT", + "ME", + "NH", + "HI", + "WV", + "ID", + "NE", + "NM", + "KS", + "MS", + "AR", + "NV", + "IA", + "UT", + "CT", + "OK", + "OR", + "KY", + "LA", + "AL", + "SC", + "MN", + "CO", + "WI", + "MD", + "MO", + "TN", + "AZ", + "IN", + "MA", + "WA", + "VA", + "NJ", + "MI", + "NC", + "GA", + "OH", + "IL", + "PA", + "NY", + "FL", + "TX" + ], + "name": "", + "type": "choropleth", + "z": [ + 17.832069098949432, + 24.789130687713623, + 36.79618835449219, + 17.061617970466614, + 15.398578345775604, + 21.27697467803955, + 29.313945770263672, + 26.793450117111206, + 22.4557027220726, + 24.7724786400795, + 12.45487630367279, + 33.40181112289429, + 25.659838318824768, + 21.114841103553772, + 18.14100295305252, + 27.640214562416077, + 25.662240386009216, + 29.32574152946472, + 24.823197722434998, + 28.496500849723816, + 20.54479867219925, + 19.75550800561905, + 27.862614393234253, + 25.476279854774475, + 34.250837564468384, + 26.028868556022644, + 29.294779896736145, + 27.947503328323364, + 26.34265422821045, + 21.6079980134964, + 25.348225235939026, + 22.315840423107147, + 31.147146224975586, + 23.717473447322845, + 27.675876021385193, + 28.14837396144867, + 23.684823513031006, + 33.08692276477814, + 26.893332600593567, + 28.87044847011566, + 28.00261676311493, + 25.444668531417847, + 26.67444348335266, + 31.93831443786621, + 22.865432500839233, + 27.36758291721344, + 26.59434676170349, + 35.37993133068085, + 31.843486428260803, + 30.435705184936523 + ] + } + ], + "layout": { + "coloraxis": { + "colorbar": { + "title": { + "text": "Poverty Rate (%)" + } + }, + "colorscale": [ + [ + 0, + "rgb(255,245,240)" + ], + [ + 0.125, + "rgb(254,224,210)" + ], + [ + 0.25, + "rgb(252,187,161)" + ], + [ + 0.375, + "rgb(252,146,114)" + ], + [ + 0.5, + "rgb(251,106,74)" + ], + [ + 0.625, + "rgb(239,59,44)" + ], + [ + 0.75, + "rgb(203,24,29)" + ], + [ + 0.875, + "rgb(165,15,21)" + ], + [ + 1, + "rgb(103,0,13)" + ] + ] + }, + "geo": { + "bgcolor": "rgba(0,0,0,0)", + "center": {}, + "domain": { + "x": [ + 0, + 1 + ], + "y": [ + 0, + 1 + ] + }, + "scope": "usa" + }, + "legend": { + "tracegroupgap": 0 + }, + "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": "SPM Poverty Rate by State (2026)" + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "# Visualization: Choropleth map of poverty rates\n", "fig_map = px.choropleth(\n", @@ -290,10 +3937,1324 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "cell-9", "metadata": {}, - "outputs": [], + "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_pct=%{customdata[0]:.1f}
Child Poverty Rate (%)=%{z:.1f}", + "hovertext": [ + "Wyoming", + "Vermont", + "District of Columbia", + "Alaska", + "North Dakota", + "South Dakota", + "Delaware", + "Rhode Island", + "Montana", + "Maine", + "New Hampshire", + "Hawaii", + "West Virginia", + "Idaho", + "Nebraska", + "New Mexico", + "Kansas", + "Mississippi", + "Arkansas", + "Nevada", + "Iowa", + "Utah", + "Connecticut", + "Oklahoma", + "Oregon", + "Kentucky", + "Louisiana", + "Alabama", + "South Carolina", + "Minnesota", + "Colorado", + "Wisconsin", + "Maryland", + "Missouri", + "Tennessee", + "Arizona", + "Indiana", + "Massachusetts", + "Washington", + "Virginia", + "New Jersey", + "Michigan", + "North Carolina", + "Georgia", + "Ohio", + "Illinois", + "Pennsylvania", + "New York", + "Florida", + "Texas" + ], + "locationmode": "USA-states", + "locations": [ + "WY", + "VT", + "DC", + "AK", + "ND", + "SD", + "DE", + "RI", + "MT", + "ME", + "NH", + "HI", + "WV", + "ID", + "NE", + "NM", + "KS", + "MS", + "AR", + "NV", + "IA", + "UT", + "CT", + "OK", + "OR", + "KY", + "LA", + "AL", + "SC", + "MN", + "CO", + "WI", + "MD", + "MO", + "TN", + "AZ", + "IN", + "MA", + "WA", + "VA", + "NJ", + "MI", + "NC", + "GA", + "OH", + "IL", + "PA", + "NY", + "FL", + "TX" + ], + "name": "", + "type": "choropleth", + "z": [ + 15.99229872226715, + 21.34946882724762, + 29.218754172325134, + 12.466702610254288, + 13.072727620601654, + 19.209976494312286, + 25.090965628623962, + 23.320218920707703, + 16.7365163564682, + 18.56364905834198, + 13.20013552904129, + 25.884070992469788, + 22.397008538246155, + 15.448057651519775, + 13.015952706336975, + 22.952669858932495, + 18.242594599723816, + 25.519615411758423, + 21.12293243408203, + 29.78779375553131, + 14.835599064826965, + 14.13036435842514, + 21.511541306972504, + 21.69877141714096, + 23.07695299386978, + 20.846913754940033, + 26.236775517463684, + 21.66508287191391, + 22.25310057401657, + 14.657293260097504, + 19.19110417366028, + 16.105875372886658, + 25.832578539848328, + 19.812971353530884, + 26.625093817710876, + 26.81792378425598, + 19.758273661136627, + 23.360145092010498, + 23.234081268310547, + 21.836182475090027, + 22.268997132778168, + 20.677094161510468, + 22.418732941150665, + 27.92282998561859, + 19.851620495319366, + 20.648689568042755, + 21.44276648759842, + 28.79577875137329, + 34.90098416805267, + 29.18386459350586 + ] + } + ], + "layout": { + "coloraxis": { + "colorbar": { + "title": { + "text": "Child Poverty Rate (%)" + } + }, + "colorscale": [ + [ + 0, + "rgb(255,245,235)" + ], + [ + 0.125, + "rgb(254,230,206)" + ], + [ + 0.25, + "rgb(253,208,162)" + ], + [ + 0.375, + "rgb(253,174,107)" + ], + [ + 0.5, + "rgb(253,141,60)" + ], + [ + 0.625, + "rgb(241,105,19)" + ], + [ + 0.75, + "rgb(217,72,1)" + ], + [ + 0.875, + "rgb(166,54,3)" + ], + [ + 1, + "rgb(127,39,4)" + ] + ] + }, + "geo": { + "bgcolor": "rgba(0,0,0,0)", + "center": {}, + "domain": { + "x": [ + 0, + 1 + ], + "y": [ + 0, + 1 + ] + }, + "scope": "usa" + }, + "legend": { + "tracegroupgap": 0 + }, + "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": "SPM Child Poverty Rate by State (2026)" + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "# Visualization: Child poverty choropleth\n", "fig_child_map = px.choropleth(\n", @@ -318,28 +5279,743 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "cell-10", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Results saved to state_poverty_rates_2026.csv\n", + "Removed checkpoint file: state_poverty_rates_2026_partial.csv\n" + ] + } + ], "source": [ "# Export to CSV\n", + "import os\n", + "\n", "output_df = df[[\"state\", \"state_name\", \"poverty_rate_pct\", \"child_poverty_rate_pct\", \n", " \"total_population\", \"child_population\", \"population_in_poverty\", \"children_in_poverty\"]].copy()\n", "output_df.columns = [\"State Code\", \"State Name\", \"Poverty Rate (%)\", \"Child Poverty Rate (%)\",\n", " \"Total Population\", \"Child Population\", \"Population in Poverty\", \"Children in Poverty\"]\n", "output_df = output_df.sort_values(\"Poverty Rate (%)\", ascending=False)\n", "\n", - "output_df.to_csv(\"state_poverty_rates.csv\", index=False)\n", - "print(f\"Results saved to state_poverty_rates.csv\")" + "# Save final CSV\n", + "output_filename = f\"state_poverty_rates_{ANALYSIS_YEAR}.csv\"\n", + "output_df.to_csv(output_filename, index=False)\n", + "print(f\"Results saved to {output_filename}\")\n", + "\n", + "# Clean up intermediate checkpoint file\n", + "if os.path.exists(intermediate_file):\n", + " os.remove(intermediate_file)\n", + " print(f\"Removed checkpoint file: {intermediate_file}\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "cell-11", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "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", + " \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", + " \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", + " \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", + "
State CodeState NamePoverty Rate (%)Child Poverty Rate (%)Total PopulationChild PopulationPopulation in PovertyChildren in Poverty
2DCDistrict of Columbia36.829.2688,772144,009253,44242,078
47NYNew York35.428.819,979,9824,335,5877,068,9041,248,466
24OROregon34.323.14,285,052897,3871,467,666207,090
11HIHawaii33.425.91,451,218315,645484,73381,702
37MAMassachusetts33.123.47,142,0861,502,2892,363,096350,937
43GAGeorgia31.927.911,219,6422,723,6623,583,364760,523
48FLFlorida31.834.923,400,4124,808,3587,451,5071,678,164
32MDMaryland31.125.86,271,1771,467,6941,953,293379,143
49TXTexas30.429.231,307,6828,122,8609,528,7142,370,564
17MSMississippi29.325.52,976,668726,285872,930185,345
6DEDelaware29.325.11,039,111231,777304,60458,155
26LALouisiana29.326.24,624,5751,138,4501,354,759298,693
39VAVirginia28.921.88,808,4602,027,2622,543,042442,677
19NVNevada28.529.83,270,766726,141932,054216,301
35AZArizona28.126.87,569,4201,695,4812,130,669454,693
40NJNew Jersey28.022.39,539,9982,181,2642,671,449485,746
27ALAlabama27.921.75,186,4741,229,5861,449,490266,391
22CTConnecticut27.921.53,716,337787,1301,035,469169,324
34TNTennessee27.726.67,268,8761,682,2232,011,725447,893
15NMNew Mexico27.623.02,151,059475,879594,557109,227
45ILIllinois27.420.612,761,9422,898,2203,492,635598,444
38WAWashington26.923.27,993,4091,765,7562,149,694410,257
7RIRhode Island26.823.31,128,504223,834302,36552,198
42NCNorth Carolina26.722.411,035,4002,518,4022,943,632564,594
46PAPennsylvania26.621.413,160,5922,868,2443,499,974615,031
28SCSouth Carolina26.322.35,504,3521,240,5361,449,993276,058
25KYKentucky26.020.84,606,8711,092,9001,199,116227,836
16KSKansas25.718.23,012,524747,167773,081136,303
12WVWest Virginia25.722.41,759,224376,035451,41484,221
23OKOklahoma25.521.74,082,8241,025,5401,040,152222,530
41MIMichigan25.420.710,167,0902,270,7402,586,982469,523
30COColorado25.319.25,949,2641,300,7901,508,033249,636
18ARArkansas24.821.13,098,966750,715769,262158,573
1VTVermont24.821.3654,492123,710162,24326,411
9MEMaine24.818.61,415,236266,199350,58949,416
33MOMissouri23.719.86,281,9681,463,9291,489,924290,048
36INIndiana23.719.86,999,3681,704,8001,657,788336,839
44OHOhio22.919.911,972,2722,754,1822,737,512546,750
8MTMontana22.516.71,149,116246,726258,04241,293
31WIWisconsin22.316.16,003,1451,327,2171,339,652213,760
29MNMinnesota21.614.75,813,4331,380,6101,256,166202,360
5SDSouth Dakota21.319.2933,974233,976198,72144,947
13IDIdaho21.115.41,977,166498,487417,47677,006
20IAIowa20.514.83,244,085782,335666,491116,064
21UTUtah19.814.13,455,203972,374682,593137,400
14NENebraska18.113.02,022,241508,053366,85566,128
0WYWyoming17.816.0599,583133,008106,91821,271
3AKAlaska17.112.5740,242178,709126,29722,279
4NDNorth Dakota15.413.1793,403190,323122,17324,880
10NHNew Hampshire12.513.21,425,187263,602177,50534,796
\n", + "
" + ], + "text/plain": [ + " State Code State Name Poverty Rate (%) Child Poverty Rate (%) \\\n", + "2 DC District of Columbia 36.8 29.2 \n", + "47 NY New York 35.4 28.8 \n", + "24 OR Oregon 34.3 23.1 \n", + "11 HI Hawaii 33.4 25.9 \n", + "37 MA Massachusetts 33.1 23.4 \n", + "43 GA Georgia 31.9 27.9 \n", + "48 FL Florida 31.8 34.9 \n", + "32 MD Maryland 31.1 25.8 \n", + "49 TX Texas 30.4 29.2 \n", + "17 MS Mississippi 29.3 25.5 \n", + "6 DE Delaware 29.3 25.1 \n", + "26 LA Louisiana 29.3 26.2 \n", + "39 VA Virginia 28.9 21.8 \n", + "19 NV Nevada 28.5 29.8 \n", + "35 AZ Arizona 28.1 26.8 \n", + "40 NJ New Jersey 28.0 22.3 \n", + "27 AL Alabama 27.9 21.7 \n", + "22 CT Connecticut 27.9 21.5 \n", + "34 TN Tennessee 27.7 26.6 \n", + "15 NM New Mexico 27.6 23.0 \n", + "45 IL Illinois 27.4 20.6 \n", + "38 WA Washington 26.9 23.2 \n", + "7 RI Rhode Island 26.8 23.3 \n", + "42 NC North Carolina 26.7 22.4 \n", + "46 PA Pennsylvania 26.6 21.4 \n", + "28 SC South Carolina 26.3 22.3 \n", + "25 KY Kentucky 26.0 20.8 \n", + "16 KS Kansas 25.7 18.2 \n", + "12 WV West Virginia 25.7 22.4 \n", + "23 OK Oklahoma 25.5 21.7 \n", + "41 MI Michigan 25.4 20.7 \n", + "30 CO Colorado 25.3 19.2 \n", + "18 AR Arkansas 24.8 21.1 \n", + "1 VT Vermont 24.8 21.3 \n", + "9 ME Maine 24.8 18.6 \n", + "33 MO Missouri 23.7 19.8 \n", + "36 IN Indiana 23.7 19.8 \n", + "44 OH Ohio 22.9 19.9 \n", + "8 MT Montana 22.5 16.7 \n", + "31 WI Wisconsin 22.3 16.1 \n", + "29 MN Minnesota 21.6 14.7 \n", + "5 SD South Dakota 21.3 19.2 \n", + "13 ID Idaho 21.1 15.4 \n", + "20 IA Iowa 20.5 14.8 \n", + "21 UT Utah 19.8 14.1 \n", + "14 NE Nebraska 18.1 13.0 \n", + "0 WY Wyoming 17.8 16.0 \n", + "3 AK Alaska 17.1 12.5 \n", + "4 ND North Dakota 15.4 13.1 \n", + "10 NH New Hampshire 12.5 13.2 \n", + "\n", + " Total Population Child Population Population in Poverty Children in Poverty \n", + "2 688,772 144,009 253,442 42,078 \n", + "47 19,979,982 4,335,587 7,068,904 1,248,466 \n", + "24 4,285,052 897,387 1,467,666 207,090 \n", + "11 1,451,218 315,645 484,733 81,702 \n", + "37 7,142,086 1,502,289 2,363,096 350,937 \n", + "43 11,219,642 2,723,662 3,583,364 760,523 \n", + "48 23,400,412 4,808,358 7,451,507 1,678,164 \n", + "32 6,271,177 1,467,694 1,953,293 379,143 \n", + "49 31,307,682 8,122,860 9,528,714 2,370,564 \n", + "17 2,976,668 726,285 872,930 185,345 \n", + "6 1,039,111 231,777 304,604 58,155 \n", + "26 4,624,575 1,138,450 1,354,759 298,693 \n", + "39 8,808,460 2,027,262 2,543,042 442,677 \n", + "19 3,270,766 726,141 932,054 216,301 \n", + "35 7,569,420 1,695,481 2,130,669 454,693 \n", + "40 9,539,998 2,181,264 2,671,449 485,746 \n", + "27 5,186,474 1,229,586 1,449,490 266,391 \n", + "22 3,716,337 787,130 1,035,469 169,324 \n", + "34 7,268,876 1,682,223 2,011,725 447,893 \n", + "15 2,151,059 475,879 594,557 109,227 \n", + "45 12,761,942 2,898,220 3,492,635 598,444 \n", + "38 7,993,409 1,765,756 2,149,694 410,257 \n", + "7 1,128,504 223,834 302,365 52,198 \n", + "42 11,035,400 2,518,402 2,943,632 564,594 \n", + "46 13,160,592 2,868,244 3,499,974 615,031 \n", + "28 5,504,352 1,240,536 1,449,993 276,058 \n", + "25 4,606,871 1,092,900 1,199,116 227,836 \n", + "16 3,012,524 747,167 773,081 136,303 \n", + "12 1,759,224 376,035 451,414 84,221 \n", + "23 4,082,824 1,025,540 1,040,152 222,530 \n", + "41 10,167,090 2,270,740 2,586,982 469,523 \n", + "30 5,949,264 1,300,790 1,508,033 249,636 \n", + "18 3,098,966 750,715 769,262 158,573 \n", + "1 654,492 123,710 162,243 26,411 \n", + "9 1,415,236 266,199 350,589 49,416 \n", + "33 6,281,968 1,463,929 1,489,924 290,048 \n", + "36 6,999,368 1,704,800 1,657,788 336,839 \n", + "44 11,972,272 2,754,182 2,737,512 546,750 \n", + "8 1,149,116 246,726 258,042 41,293 \n", + "31 6,003,145 1,327,217 1,339,652 213,760 \n", + "29 5,813,433 1,380,610 1,256,166 202,360 \n", + "5 933,974 233,976 198,721 44,947 \n", + "13 1,977,166 498,487 417,476 77,006 \n", + "20 3,244,085 782,335 666,491 116,064 \n", + "21 3,455,203 972,374 682,593 137,400 \n", + "14 2,022,241 508,053 366,855 66,128 \n", + "0 599,583 133,008 106,918 21,271 \n", + "3 740,242 178,709 126,297 22,279 \n", + "4 793,403 190,323 122,173 24,880 \n", + "10 1,425,187 263,602 177,505 34,796 " + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Display full table\n", "display_df = output_df.copy()\n", @@ -360,8 +6036,16 @@ "name": "python3" }, "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", "name": "python", - "version": "3.10.0" + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.5" } }, "nbformat": 4, From 4506e0b5167563dabd69532df5361dc76b42d58e Mon Sep 17 00:00:00 2001 From: David Trimmer Date: Tue, 24 Mar 2026 12:59:36 -0400 Subject: [PATCH 3/3] Add state poverty rates CSV output for 2026 Co-Authored-By: Claude Opus 4.5 --- us/poverty/state_poverty_rates_2026.csv | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 us/poverty/state_poverty_rates_2026.csv diff --git a/us/poverty/state_poverty_rates_2026.csv b/us/poverty/state_poverty_rates_2026.csv new file mode 100644 index 0000000..4eb5e65 --- /dev/null +++ b/us/poverty/state_poverty_rates_2026.csv @@ -0,0 +1,51 @@ +State Code,State Name,Poverty Rate (%),Child Poverty Rate (%),Total Population,Child Population,Population in Poverty,Children in Poverty +DC,District of Columbia,36.79618835449219,29.218754172325134,688772.5,144008.90625,253442.03125,42077.609375 +NY,New York,35.37993133068085,28.79577875137329,19979982.0,4335587.0,7068904.0,1248466.0 +OR,Oregon,34.250837564468384,23.07695299386978,4285052.0,897387.375,1467666.25,207089.65625 +HI,Hawaii,33.40181112289429,25.884070992469788,1451218.25,315645.09375,484733.1875,81701.8046875 +MA,Massachusetts,33.08692276477814,23.360145092010498,7142086.0,1502289.25,2363096.5,350936.9375 +GA,Georgia,31.93831443786621,27.92282998561859,11219642.0,2723661.5,3583364.5,760523.375 +FL,Florida,31.843486428260803,34.90098416805267,23400412.0,4808358.5,7451507.0,1678164.375 +MD,Maryland,31.147146224975586,25.832578539848328,6271177.0,1467694.375,1953292.75,379143.3125 +TX,Texas,30.435705184936523,29.18386459350586,31307682.0,8122860.0,9528714.0,2370564.5 +MS,Mississippi,29.32574152946472,25.519615411758423,2976667.5,726284.75,872929.8125,185345.078125 +DE,Delaware,29.313945770263672,25.090965628623962,1039110.75,231776.96875,304604.375,58155.08203125 +LA,Louisiana,29.294779896736145,26.236775517463684,4624575.0,1138450.5,1354759.0,298692.71875 +VA,Virginia,28.87044847011566,21.836182475090027,8808460.0,2027262.25,2543042.0,442676.6875 +NV,Nevada,28.496500849723816,29.78779375553131,3270765.5,726140.625,932053.75,216301.28125 +AZ,Arizona,28.14837396144867,26.81792378425598,7569420.0,1695481.0,2130668.75,454692.8125 +NJ,New Jersey,28.00261676311493,22.268997132778168,9539998.0,2181264.0,2671449.0,485745.625 +AL,Alabama,27.947503328323364,21.66508287191391,5186474.0,1229586.25,1449490.0,266390.875 +CT,Connecticut,27.862614393234253,21.511541306972504,3716336.75,787130.0625,1035468.625,169323.8125 +TN,Tennessee,27.675876021385193,26.625093817710876,7268875.5,1682223.0,2011725.0,447893.4375 +NM,New Mexico,27.640214562416077,22.952669858932495,2151059.0,475879.1875,594557.3125,109226.9765625 +IL,Illinois,27.36758291721344,20.648689568042755,12761942.0,2898220.0,3492635.0,598444.4375 +WA,Washington,26.893332600593567,23.234081268310547,7993409.0,1765755.5,2149694.0,410257.0625 +RI,Rhode Island,26.793450117111206,23.320218920707703,1128503.875,223833.546875,302365.125,52198.47265625 +NC,North Carolina,26.67444348335266,22.418732941150665,11035400.0,2518402.0,2943631.5,564593.8125 +PA,Pennsylvania,26.59434676170349,21.44276648759842,13160592.0,2868243.5,3499973.5,615030.75 +SC,South Carolina,26.34265422821045,22.25310057401657,5504352.5,1240536.375,1449992.625,276057.8125 +KY,Kentucky,26.028868556022644,20.846913754940033,4606871.0,1092900.25,1199116.375,227835.96875 +KS,Kansas,25.662240386009216,18.242594599723816,3012524.5,747166.9375,773081.25,136302.640625 +WV,West Virginia,25.659838318824768,22.397008538246155,1759223.5,376035.15625,451413.90625,84220.625 +OK,Oklahoma,25.476279854774475,21.69877141714096,4082823.5,1025540.1875,1040151.5,222529.625 +MI,Michigan,25.444668531417847,20.677094161510468,10167090.0,2270740.0,2586982.25,469523.0625 +CO,Colorado,25.348225235939026,19.19110417366028,5949263.5,1300790.0,1508032.625,249635.96875 +AR,Arkansas,24.823197722434998,21.12293243408203,3098965.75,750714.875,769262.375,158573.0 +VT,Vermont,24.789130687713623,21.34946882724762,654492.25,123709.53125,162242.9375,26411.328125 +ME,Maine,24.7724786400795,18.56364905834198,1415236.25,266199.25,350589.09375,49416.29296875 +MO,Missouri,23.717473447322845,19.812971353530884,6281967.5,1463929.25,1489924.0,290047.875 +IN,Indiana,23.684823513031006,19.758273661136627,6999368.0,1704799.75,1657788.0,336839.0 +OH,Ohio,22.865432500839233,19.851620495319366,11972272.0,2754182.0,2737511.75,546749.75 +MT,Montana,22.4557027220726,16.7365163564682,1149116.5,246726.046875,258042.1875,41293.34375 +WI,Wisconsin,22.315840423107147,16.105875372886658,6003145.0,1327217.125,1339652.25,213759.9375 +MN,Minnesota,21.6079980134964,14.657293260097504,5813433.0,1380609.875,1256166.5,202360.046875 +SD,South Dakota,21.27697467803955,19.209976494312286,933974.125,233975.953125,198721.4375,44946.7265625 +ID,Idaho,21.114841103553772,15.448057651519775,1977166.125,498486.625,417475.5,77006.5 +IA,Iowa,20.54479867219925,14.835599064826965,3244085.0,782335.375,666490.75,116064.140625 +UT,Utah,19.75550800561905,14.13036435842514,3455203.25,972374.5,682592.9375,137400.0625 +NE,Nebraska,18.14100295305252,13.015952706336975,2022241.375,508053.125,366854.875,66127.953125 +WY,Wyoming,17.832069098949432,15.99229872226715,599583.375,133007.59375,106918.125,21270.97265625 +AK,Alaska,17.061617970466614,12.466702610254288,740241.5,178708.921875,126297.1796875,22279.109375 +ND,North Dakota,15.398578345775604,13.072727620601654,793403.0,190322.625,122172.78125,24880.359375 +NH,New Hampshire,12.45487630367279,13.20013552904129,1425187.0,263602.125,177505.28125,34795.8359375