ruality analysis . updated databases

This commit is contained in:
2025-08-06 10:08:44 -07:00
parent afff5eebd4
commit f4d1166502
20 changed files with 148965 additions and 70170 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -0,0 +1,80 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "00abdbfd",
"metadata": {},
"source": [
"## Colorado Spills Project\n",
"### incorporating rurality data\n",
"### Date: 2025-08-06\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "3dc76f74",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import geopandas as gpd\n",
"import statsmodels.formula.api as smf\n",
"from sqlalchemy import create_engine\n",
"from dotenv import load_dotenv\n",
"import os\n",
"\n",
"load_dotenv()\n",
"\n",
"# Connect to your database\n",
"engine = create_engine(f\"postgresql+psycopg2://{os.getenv('DB_USER')}:{os.getenv('DB_PASSWORD')}@{os.getenv('DB_HOST')}:{os.getenv('DB_PORT')}/colorado_spills\")\n",
"\n",
"# Load data with geometry preserved\n",
"spills = gpd.read_postgis(\"SELECT * FROM spills_with_ruca\", engine, geom_col='geometry')\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "7e7219b8",
"metadata": {},
"outputs": [],
"source": [
"def classify_rurality(ruca_code):\n",
" if pd.isna(ruca_code):\n",
" return 'Unknown'\n",
" elif ruca_code <= 3:\n",
" return 'Urban'\n",
" elif ruca_code <= 6:\n",
" return 'Suburban'\n",
" else:\n",
" return 'Rural'\n",
"\n",
"spills['ruca_code'] = pd.to_numeric(spills['ruca_code'], errors='coerce')\n",
"spills['rurality'] = spills['ruca_code'].apply(classify_rurality)\n",
"spills = spills[spills['rurality'] != 'Unknown'] # drop unknowns\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

85529
data/RUCA-codes-2020-tract.csv Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,26 +0,0 @@
{
"statistical_tests": {
"income_chi2": {
"statistic": 361.6935464772055,
"p_value": 4.380770869774385e-78
},
"poverty_binomial": {
"p_value": 0.011555516170195554,
"observed_ratio": 1.0352279455298994
},
"major_spills_ztest": {
"z_statistic": 11.59802883494945,
"p_value": 4.216789863971777e-31
},
"minority_binomial": {
"p_value": 1.0,
"observed_ratio": 0.20663114268798105
}
},
"spatial_analysis": {
"n_clusters": 259,
"max_density": 119
},
"regression_summary": " OLS Regression Results \n==============================================================================\nDep. Variable: major_spill R-squared: 0.055\nModel: OLS Adj. R-squared: 0.054\nMethod: Least Squares F-statistic: 195.2\nDate: Fri, 04 Jul 2025 Prob (F-statistic): 6.68e-203\nTime: 23:57:30 Log-Likelihood: -10133.\nNo. Observations: 16886 AIC: 2.028e+04\nDf Residuals: 16880 BIC: 2.033e+04\nDf Model: 5 \nCovariance Type: nonrobust \n===========================================================================================\n coef std err t P>|t| [0.025 0.975]\n-------------------------------------------------------------------------------------------\nIntercept -0.1181 0.040 -2.951 0.003 -0.197 -0.040\npercent_poverty 0.0096 0.001 14.132 0.000 0.008 0.011\npercent_white 0.0046 0.000 11.014 0.000 0.004 0.005\nmedian_household_income -9.759e-07 1.78e-07 -5.492 0.000 -1.32e-06 -6.28e-07\nlat_norm -0.0229 0.004 -5.935 0.000 -0.030 -0.015\nlon_norm -0.0569 0.004 -15.058 0.000 -0.064 -0.049\n==============================================================================\nOmnibus: 5689.237 Durbin-Watson: 1.525\nProb(Omnibus): 0.000 Jarque-Bera (JB): 2753.023\nSkew: 0.850 Prob(JB): 0.00\nKurtosis: 1.988 Cond. No. 9.78e+05\n==============================================================================\n\nNotes:\n[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n[2] The condition number is large, 9.78e+05. This might indicate that there are\nstrong multicollinearity or other numerical problems.",
"academic_interpretation": " Title: Environmental Justice Implications of Oil and Gas Spills: A Statistical and Spatial Analysis\n\nAbstract:\nThis study investigates the environmental justice implications of oil and gas spills in a given region using comprehensive statistical and spatial analysis. The findings reveal significant demographic disparities, spatial clustering patterns, and persistence of these disparities even after accounting for geographic factors, highlighting the need for policy interventions to address environmental injustice.\n\nIntroduction:\nEnvironmental justice is a critical concern as marginalized communities often bear the brunt of industrial pollution. This study analyzes oil and gas spills data in our region, focusing on demographic disparities, spatial clustering patterns, and their implications for policy.\n\n1. Statistical Significance of Demographic Disparities:\nStatistical analyses revealed significant disparities based on income distribution (p-value < 0.05) and minority community composition (ratio = 0.21x). Moreover, poverty is over-represented in areas with oil and gas spills (1.04x), suggesting a disproportionate burden on low-income communities.\n\n2. Spatial Clustering Patterns and Their Implications:\nSpatial analysis identified 259 clusters, many of which had high concentrations of spills per 5km grid (up to 119 spills). This spatial autocorrelation in poverty patterns indicates the existence of environmental justice issues.\n\n3. Persistence of Disparities After Controlling for Spatial Effects:\nAfter accounting for geographic clustering effects, disparities in oil and gas spill incidents persisted (p-value < 0.05), suggesting that marginalized communities remain disproportionately affected by these incidents.\n\n4. Methodological Strengths and Limitations:\nThe study's strength lies in its use of rigorous statistical tests and spatial analysis to understand environmental justice issues. However, it is limited by the availability and quality of data, and future research should consider additional factors that may influence spill incidents.\n\n5. Policy Implications for Environmental Justice:\nPolicy interventions are required to mitigate these environmental justice issues. This includes improved monitoring and enforcement of oil and gas facilities, stricter regulations on facility locations, and targeted community outreach programs.\n\n6. Recommendations for Further Research:\nFuture research should focus on identifying the underlying mechanisms leading to spatial clustering patterns of oil and gas spills in marginalized communities. Additionally, examining the long-term health and economic impacts of these incidents on affected communities is crucial for informing policy decisions.\n\nConclusion:\nThis study provides evidence of environmental justice issues related to oil and gas spills in our region. The disproportionate burden on low-income communities and spatial clustering patterns indicate the need for urgent policy action. Future research should further explore these findings to inform effective policy interventions that promote environmental justice."
}

Binary file not shown.

View File

@@ -4,7 +4,24 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "ValueError",
"evalue": "invalid literal for int() with base 10: 'None'",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mValueError\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[1]\u001b[39m\u001b[32m, line 16\u001b[39m\n\u001b[32m 12\u001b[39m port = os.getenv(\u001b[33m'\u001b[39m\u001b[33mDB_PORT\u001b[39m\u001b[33m'\u001b[39m)\n\u001b[32m 15\u001b[39m \u001b[38;5;66;03m# Create an engine to connect to the PostgreSQL database\u001b[39;00m\n\u001b[32m---> \u001b[39m\u001b[32m16\u001b[39m engine = \u001b[43mcreate_engine\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43mf\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[33;43mpostgresql+psycopg2://\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43muser\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[33;43m:\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mpassword\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[33;43m@\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mhost\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[33;43m:\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mport\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[33;43m/\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mdb_name\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[33;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[32m 18\u001b[39m \u001b[38;5;66;03m# Read in the spills_with_demographics as spills\u001b[39;00m\n\u001b[32m 19\u001b[39m spills = pd.read_sql_table(\u001b[33m'\u001b[39m\u001b[33mspills_with_demographics\u001b[39m\u001b[33m'\u001b[39m, engine)\n",
"\u001b[36mFile \u001b[39m\u001b[32m<string>:2\u001b[39m, in \u001b[36mcreate_engine\u001b[39m\u001b[34m(url, **kwargs)\u001b[39m\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/miniconda3/lib/python3.12/site-packages/sqlalchemy/util/deprecations.py:281\u001b[39m, in \u001b[36mdeprecated_params.<locals>.decorate.<locals>.warned\u001b[39m\u001b[34m(fn, *args, **kwargs)\u001b[39m\n\u001b[32m 274\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m m \u001b[38;5;129;01min\u001b[39;00m kwargs:\n\u001b[32m 275\u001b[39m _warn_with_version(\n\u001b[32m 276\u001b[39m messages[m],\n\u001b[32m 277\u001b[39m versions[m],\n\u001b[32m 278\u001b[39m version_warnings[m],\n\u001b[32m 279\u001b[39m stacklevel=\u001b[32m3\u001b[39m,\n\u001b[32m 280\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m281\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/miniconda3/lib/python3.12/site-packages/sqlalchemy/engine/create.py:549\u001b[39m, in \u001b[36mcreate_engine\u001b[39m\u001b[34m(url, **kwargs)\u001b[39m\n\u001b[32m 546\u001b[39m kwargs.pop(\u001b[33m\"\u001b[39m\u001b[33mempty_in_strategy\u001b[39m\u001b[33m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[32m 548\u001b[39m \u001b[38;5;66;03m# create url.URL object\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m549\u001b[39m u = \u001b[43m_url\u001b[49m\u001b[43m.\u001b[49m\u001b[43mmake_url\u001b[49m\u001b[43m(\u001b[49m\u001b[43murl\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 551\u001b[39m u, plugins, kwargs = u._instantiate_plugins(kwargs)\n\u001b[32m 553\u001b[39m entrypoint = u._get_entrypoint()\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/miniconda3/lib/python3.12/site-packages/sqlalchemy/engine/url.py:856\u001b[39m, in \u001b[36mmake_url\u001b[39m\u001b[34m(name_or_url)\u001b[39m\n\u001b[32m 840\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\"Given a string, produce a new URL instance.\u001b[39;00m\n\u001b[32m 841\u001b[39m \n\u001b[32m 842\u001b[39m \u001b[33;03mThe format of the URL generally follows `RFC-1738\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 852\u001b[39m \n\u001b[32m 853\u001b[39m \u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 855\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(name_or_url, \u001b[38;5;28mstr\u001b[39m):\n\u001b[32m--> \u001b[39m\u001b[32m856\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_parse_url\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname_or_url\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 857\u001b[39m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(name_or_url, URL) \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mhasattr\u001b[39m(\n\u001b[32m 858\u001b[39m name_or_url, \u001b[33m\"\u001b[39m\u001b[33m_sqla_is_testing_if_this_is_a_mock_object\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 859\u001b[39m ):\n\u001b[32m 860\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m exc.ArgumentError(\n\u001b[32m 861\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mExpected string or URL object, got \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mname_or_url\u001b[38;5;132;01m!r}\u001b[39;00m\u001b[33m\"\u001b[39m\n\u001b[32m 862\u001b[39m )\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/miniconda3/lib/python3.12/site-packages/sqlalchemy/engine/url.py:917\u001b[39m, in \u001b[36m_parse_url\u001b[39m\u001b[34m(name)\u001b[39m\n\u001b[32m 914\u001b[39m name = components.pop(\u001b[33m\"\u001b[39m\u001b[33mname\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 916\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m components[\u001b[33m\"\u001b[39m\u001b[33mport\u001b[39m\u001b[33m\"\u001b[39m]:\n\u001b[32m--> \u001b[39m\u001b[32m917\u001b[39m components[\u001b[33m\"\u001b[39m\u001b[33mport\u001b[39m\u001b[33m\"\u001b[39m] = \u001b[38;5;28;43mint\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mcomponents\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mport\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 919\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m URL.create(name, **components) \u001b[38;5;66;03m# type: ignore\u001b[39;00m\n\u001b[32m 921\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n",
"\u001b[31mValueError\u001b[39m: invalid literal for int() with base 10: 'None'"
]
}
],
"source": [
"import pandas as pd\n",
"from sqlalchemy import create_engine\n",
@@ -31,7 +48,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -41,7 +58,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -51,7 +68,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -71,7 +88,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "funkyfunk",
"display_name": "base",
"language": "python",
"name": "python3"
},
@@ -85,7 +102,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.12.7"
}
},
"nbformat": 4,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [
{
@@ -19,7 +19,7 @@
"import psycopg2\n",
"\n",
"# Step 1: Load the Excel file into a DataFrame\n",
"file_path = '/home/dadams/Repos/colorado_spills/Spills.xlsx'\n",
"file_path = 'Spills.xlsx'\n",
"df = pd.read_excel(file_path)\n",
"\n",
"\n",
@@ -38,10 +38,6 @@
"conn.autocommit = True\n",
"cur = conn.cursor()\n",
"\n",
"# Create database\n",
"cur.execute(f'CREATE DATABASE {db_name}')\n",
"cur.close()\n",
"conn.close()\n",
"\n",
"# Connect to the new database\n",
"engine = create_engine(f'postgresql+psycopg2://{user}:{password}@{host}:{port}/{db_name}')\n",
@@ -49,10 +45,6 @@
"conn.autocommit = True\n",
"cur = conn.cursor()\n",
"\n",
"# Enable PostGIS extension\n",
"cur.execute('CREATE EXTENSION postgis')\n",
"cur.close()\n",
"conn.close()\n",
"\n",
"# Step 3: Load DataFrame into PostgreSQL table\n",
"table_name = 'spills'\n",
@@ -64,7 +56,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "funkyfunk",
"display_name": "base",
"language": "python",
"name": "python3"
},
@@ -78,7 +70,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.12.7"
}
},
"nbformat": 4,

File diff suppressed because one or more lines are too long

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@@ -13,135 +13,246 @@
"import os\n",
"\n",
"# Database connection details from zshrc environment variables\n",
"# Step 2: Create PostgreSQL database and enable PostGIS\n",
"db_name = 'colorado_spills'\n",
"user = os.getenv('DB_USER')\n",
"password = os.getenv('DB_PASSWORD')\n",
"host = os.getenv('DB_HOST')\n",
"port = os.getenv('DB_PORT')\n",
"\n",
"user = 'postgres'\n",
"password = 'MandyLinkToby3'\n",
"host = '192.168.0.74'\n",
"port = '5432'\n",
"\n",
"# Create an engine to connect to the PostgreSQL database\n",
"engine = create_engine(f'postgresql+psycopg2://{user}:{password}@{host}:{port}/{db_name}')\n",
"\n",
"# Read in the spills_with_demographics as spills\n",
"spills_df = pd.read_sql_table('spills_with_demographics', engine)\n",
"spills_gdf = pd.read_sql_table('spills_with_demographics', engine)\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<bound method NDFrame.head of Document # Report Operator \\\n",
"0 400628833 I w/S GREAT WESTERN OPERATING COMPANY LLC \n",
"1 400629910 I COLORADO OIL & GAS CONSERVATION COMMISSION \n",
"2 400629998 S COLORADO OIL & GAS CONSERVATION COMMISSION \n",
"3 400630821 I KERR MCGEE GATHERING LLC \n",
"4 400631216 I NOBLE ENERGY INC \n",
"... ... ... ... \n",
"16885 403825450 I w/S NOBLE ENERGY INC \n",
"16886 403825485 I w/S NOBLE ENERGY INC \n",
"16887 403825575 I w/S NOBLE ENERGY INC \n",
"16888 403826200 I NOBLE ENERGY INC \n",
"16889 403826294 I CAERUS PICEANCE LLC \n",
"<bound method NDFrame.head of Document # Report Operator Operator # \\\n",
"0 400811665 I w/S CHEVRON USA INC 16700 \n",
"1 400811979 I WHITING OIL & GAS CORPORATION 96155 \n",
"2 400812102 I w/S CHEVRON USA INC 16700 \n",
"3 400812258 I KERR MCGEE OIL & GAS ONSHORE LP 47120 \n",
"4 400812277 I NOBLE ENERGY INC 100322 \n",
"... ... ... ... ... \n",
"17815 404127660 I w/S NOBLE ENERGY INC 100322 \n",
"17816 404129149 I KERR MCGEE OIL & GAS ONSHORE LP 47120 \n",
"17817 404129437 S NOBLE ENERGY INC 100322 \n",
"17818 404129549 I w/S NOBLE ENERGY INC 100322 \n",
"17819 404130067 I w/S NOBLE ENERGY INC 100322 \n",
"\n",
" Operator # Tracking # Initial Report Date Date of Discovery \\\n",
"0 10110 400628833 06/18/2014 06/11/2014 \n",
"1 5 400629910 06/19/2014 06/14/2014 \n",
"2 5 400629910 06/19/2014 06/14/2014 \n",
"3 47121 400630821 06/20/2014 06/19/2014 \n",
"4 100322 400631216 06/23/2014 06/20/2014 \n",
"... ... ... ... ... \n",
"16885 100322 403825450 06/14/2024 06/13/2024 \n",
"16886 100322 403825485 06/14/2024 06/13/2024 \n",
"16887 100322 403825575 06/14/2024 06/13/2024 \n",
"16888 100322 403826200 06/14/2024 06/14/2024 \n",
"16889 10456 403826294 06/15/2024 06/15/2024 \n",
" Tracking # Initial Report Date Date of Discovery Spill Type Qtr Qtr \\\n",
"0 400811665 03/19/2015 06/04/2012 Historical nwne \n",
"1 400811979 03/19/2015 03/18/2015 Recent SWSW \n",
"2 400812102 03/19/2015 07/11/2012 Historical nese \n",
"3 400812258 03/20/2015 03/19/2015 Historical NENW \n",
"4 400812277 03/20/2015 03/18/2015 Recent SENE \n",
"... ... ... ... ... ... \n",
"17815 404127660 03/14/2025 03/13/2025 Historical SESW \n",
"17816 404129149 03/14/2025 03/14/2025 Recent SWSW \n",
"17817 404034519 12/18/2024 12/17/2024 Historical SENE \n",
"17818 404129549 03/17/2025 03/14/2025 Historical SWSW \n",
"17819 404130067 03/17/2025 03/14/2025 Historical SWSW \n",
"\n",
" Spill Type Qtr Qtr Section ... total_population white_population \\\n",
"0 Historical SESE 2 ... 5491.0 4767.0 \n",
"1 Historical NWNE 1 ... 7335.0 6302.0 \n",
"2 Historical NWNE 1 ... 7335.0 6302.0 \n",
"3 Recent NWNW 15 ... 427.0 222.0 \n",
"4 Recent NENW 36 ... 3470.0 3105.0 \n",
"... ... ... ... ... ... ... \n",
"16885 Historical SWSE 7 ... 7335.0 6302.0 \n",
"16886 Historical SWSE 7 ... 7335.0 6302.0 \n",
"16887 Historical SWSE 7 ... 7335.0 6302.0 \n",
"16888 Recent SWSE 5 ... 4023.0 3581.0 \n",
"16889 Recent NESW 22 ... 7240.0 5646.0 \n",
" Section ... total_population white_population hispanic_population \\\n",
"0 19 ... 2532.0 2144.0 295.0 \n",
"1 33 ... 5870.0 5052.0 846.0 \n",
"2 32 ... 2532.0 2144.0 295.0 \n",
"3 13 ... 1343.0 1106.0 245.0 \n",
"4 28 ... 4023.0 3581.0 612.0 \n",
"... ... ... ... ... ... \n",
"17815 17 ... 6045.0 4762.0 2344.0 \n",
"17816 20 ... 2394.0 2295.0 284.0 \n",
"17817 19 ... 6045.0 4762.0 2344.0 \n",
"17818 17 ... 6045.0 4762.0 2344.0 \n",
"17819 17 ... 6045.0 4762.0 2344.0 \n",
"\n",
" hispanic_population median_household_income poverty_population \\\n",
"0 772.0 88286.0 325.0 \n",
"1 2011.0 71440.0 831.0 \n",
"2 2011.0 71440.0 831.0 \n",
"3 183.0 -666666666.0 0.0 \n",
"4 167.0 122604.0 129.0 \n",
"... ... ... ... \n",
"16885 2011.0 71440.0 831.0 \n",
"16886 2011.0 71440.0 831.0 \n",
"16887 2011.0 71440.0 831.0 \n",
"16888 612.0 82865.0 268.0 \n",
"16889 1659.0 64573.0 693.0 \n",
" median_household_income poverty_population unemployed_population \\\n",
"0 59718.0 249.0 86.0 \n",
"1 72717.0 1193.0 253.0 \n",
"2 59718.0 249.0 86.0 \n",
"3 140588.0 25.0 10.0 \n",
"4 82865.0 268.0 62.0 \n",
"... ... ... ... \n",
"17815 73214.0 467.0 110.0 \n",
"17816 119518.0 44.0 145.0 \n",
"17817 73214.0 467.0 110.0 \n",
"17818 73214.0 467.0 110.0 \n",
"17819 73214.0 467.0 110.0 \n",
"\n",
" unemployed_population percent_white percent_hispanic percent_poverty \\\n",
"0 80.0 86.814788 14.059370 5.918776 \n",
"1 166.0 85.916837 27.416496 11.329243 \n",
"2 166.0 85.916837 27.416496 11.329243 \n",
"3 0.0 51.990632 42.857143 0.000000 \n",
"4 13.0 89.481268 4.812680 3.717579 \n",
"... ... ... ... ... \n",
"16885 166.0 85.916837 27.416496 11.329243 \n",
"16886 166.0 85.916837 27.416496 11.329243 \n",
"16887 166.0 85.916837 27.416496 11.329243 \n",
"16888 62.0 89.013174 15.212528 6.661695 \n",
"16889 240.0 77.983425 22.914365 9.571823 \n",
" percent_white percent_hispanic percent_poverty unemployment_rate \n",
"0 84.676145 11.650869 9.834123 3.396524 \n",
"1 86.064736 14.412266 20.323680 4.310051 \n",
"2 84.676145 11.650869 9.834123 3.396524 \n",
"3 82.352941 18.242740 1.861504 0.744602 \n",
"4 89.013174 15.212528 6.661695 1.541138 \n",
"... ... ... ... ... \n",
"17815 78.775848 38.775848 7.725393 1.819686 \n",
"17816 95.864662 11.862991 1.837928 6.056809 \n",
"17817 78.775848 38.775848 7.725393 1.819686 \n",
"17818 78.775848 38.775848 7.725393 1.819686 \n",
"17819 78.775848 38.775848 7.725393 1.819686 \n",
"\n",
" unemployment_rate \n",
"0 1.456930 \n",
"1 2.263122 \n",
"2 2.263122 \n",
"3 0.000000 \n",
"4 0.374640 \n",
"... ... \n",
"16885 2.263122 \n",
"16886 2.263122 \n",
"16887 2.263122 \n",
"16888 1.541138 \n",
"16889 3.314917 \n",
"\n",
"[16890 rows x 118 columns]>"
"[17820 rows x 118 columns]>"
]
},
"execution_count": 4,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"spills_df.head"
"spills_gdf.head"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 9,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'spills_gdf' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[5], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Ensure the date columns are in datetime format\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m spills_gdf[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mDate of Discovery\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mto_datetime(\u001b[43mspills_gdf\u001b[49m[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mDate of Discovery\u001b[39m\u001b[38;5;124m'\u001b[39m])\n\u001b[1;32m 3\u001b[0m spills_gdf[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mInitial Report Date\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mto_datetime(spills_gdf[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mInitial Report Date\u001b[39m\u001b[38;5;124m'\u001b[39m])\n\u001b[1;32m 5\u001b[0m \u001b[38;5;66;03m# Calculate the time difference in days\u001b[39;00m\n",
"\u001b[0;31mNameError\u001b[0m: name 'spills_gdf' is not defined"
]
"data": {
"application/vnd.microsoft.datawrangler.viewer.v0+json": {
"columns": [
{
"name": "index",
"rawType": "int64",
"type": "integer"
},
{
"name": "Date of Discovery",
"rawType": "datetime64[ns]",
"type": "datetime"
},
{
"name": "Initial Report Date",
"rawType": "datetime64[ns]",
"type": "datetime"
},
{
"name": "Report Delay (Days)",
"rawType": "int64",
"type": "integer"
}
],
"ref": "3818e92a-d9e1-423d-bb6a-a537978686c7",
"rows": [
[
"0",
"2012-06-04 00:00:00",
"2015-03-19 00:00:00",
"1018"
],
[
"1",
"2015-03-18 00:00:00",
"2015-03-19 00:00:00",
"1"
],
[
"2",
"2012-07-11 00:00:00",
"2015-03-19 00:00:00",
"981"
],
[
"3",
"2015-03-19 00:00:00",
"2015-03-20 00:00:00",
"1"
],
[
"4",
"2015-03-18 00:00:00",
"2015-03-20 00:00:00",
"2"
]
],
"shape": {
"columns": 3,
"rows": 5
}
},
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Date of Discovery</th>\n",
" <th>Initial Report Date</th>\n",
" <th>Report Delay (Days)</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2012-06-04</td>\n",
" <td>2015-03-19</td>\n",
" <td>1018</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2015-03-18</td>\n",
" <td>2015-03-19</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2012-07-11</td>\n",
" <td>2015-03-19</td>\n",
" <td>981</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2015-03-19</td>\n",
" <td>2015-03-20</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2015-03-18</td>\n",
" <td>2015-03-20</td>\n",
" <td>2</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Date of Discovery Initial Report Date Report Delay (Days)\n",
"0 2012-06-04 2015-03-19 1018\n",
"1 2015-03-18 2015-03-19 1\n",
"2 2012-07-11 2015-03-19 981\n",
"3 2015-03-19 2015-03-20 1\n",
"4 2015-03-18 2015-03-20 2"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
@@ -159,7 +270,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "funkyfunk",
"display_name": "base",
"language": "python",
"name": "python3"
},
@@ -173,7 +284,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.12.7"
}
},
"nbformat": 4,