2021
This commit is contained in:
@@ -6,11 +6,14 @@
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/home/dadams/miniconda3/envs/spatial_env2/lib/python3.10/site-packages/pandas/io/sql.py:1725: SAWarning: Did not recognize type 'geometry' of column 'geometry'\n",
|
||||
" self.meta.reflect(bind=self.con, only=[table_name], views=True)\n"
|
||||
"ename": "ModuleNotFoundError",
|
||||
"evalue": "No module named 'geopandas'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
|
||||
"Cell \u001b[0;32mIn[1], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpandas\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mpd\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01msqlalchemy\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m create_engine\n\u001b[0;32m----> 3\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mgeopandas\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mgpd\u001b[39;00m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mdotenv\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m load_dotenv\n\u001b[1;32m 5\u001b[0m load_dotenv()\n",
|
||||
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'geopandas'"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -44,7 +47,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -54,7 +57,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -63,7 +66,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -76,7 +79,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -87,7 +90,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -109,7 +112,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -137,7 +140,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -183,7 +186,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -214,7 +217,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -263,7 +266,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -278,8 +281,8 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Add a column to indicate whether the spill occurred before or after 2019\n",
|
||||
"spills_gdf['Period'] = spills_gdf['Report Year'].apply(lambda x: 'Before 2019' if x < 2019 else '2019 and After')\n",
|
||||
"# Add a column to indicate whether the spill occurred before or after 2021\n",
|
||||
"spills_gdf['Period'] = spills_gdf['Report Year'].apply(lambda x: 'Before 2021' if x < 2021 else '2021 and After')\n",
|
||||
"\n",
|
||||
"# Group by the new period column and calculate the mean response time\n",
|
||||
"response_time_summary = spills_gdf.groupby('Period')['Report Delay (Days)'].describe()\n",
|
||||
@@ -288,7 +291,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -322,13 +325,13 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# t-test for the difference in response time before and after 2019\n",
|
||||
"# t-test for the difference in response time before and after 2021\n",
|
||||
"from scipy.stats import ttest_ind\n",
|
||||
"\n",
|
||||
"before_2019 = spills_gdf[spills_gdf['Period'] == 'Before 2019']['Report Delay (Days)']\n",
|
||||
"after_2019 = spills_gdf[spills_gdf['Period'] == '2019 and After']['Report Delay (Days)']\n",
|
||||
"before_2021 = spills_gdf[spills_gdf['Period'] == 'Before 2021']['Report Delay (Days)']\n",
|
||||
"after_2021 = spills_gdf[spills_gdf['Period'] == '2021 and After']['Report Delay (Days)']\n",
|
||||
"\n",
|
||||
"t_stat, p_value = ttest_ind(before_2019, after_2019, equal_var=False)\n",
|
||||
"t_stat, p_value = ttest_ind(before_2021, after_2021, equal_var=False)\n",
|
||||
"print(f'T-Statistic: {t_stat:.4f}')\n",
|
||||
"print(f'P-Value: {p_value:.4f}')\n",
|
||||
"\n",
|
||||
@@ -338,7 +341,7 @@
|
||||
"else:\n",
|
||||
" print('The difference in response time is not statistically significant.')\n",
|
||||
" \n",
|
||||
"# Create a plot for the response time distribution before and after 2019\n",
|
||||
"# Create a plot for the response time distribution before and after 2021\n",
|
||||
"fig, ax = plt.subplots(figsize=(10, 6))\n",
|
||||
"\n",
|
||||
"# Plot the response time distribution for each period\n",
|
||||
@@ -349,7 +352,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -411,9 +414,9 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Add a column to indicate whether the spill occurred before or after 2019 for historical and recent spills\n",
|
||||
"historical_spills['Period'] = historical_spills['Report Year'].apply(lambda x: 'Before 2019' if x < 2019 else '2019 and After')\n",
|
||||
"recent_spills['Period'] = recent_spills['Report Year'].apply(lambda x: 'Before 2019' if x < 2019 else '2019 and After')\n",
|
||||
"# Add a column to indicate whether the spill occurred before or after 2021 for historical and recent spills\n",
|
||||
"historical_spills['Period'] = historical_spills['Report Year'].apply(lambda x: 'Before 2021' if x < 2021 else '2021 and After')\n",
|
||||
"recent_spills['Period'] = recent_spills['Report Year'].apply(lambda x: 'Before 2021' if x < 2021 else '2021 and After')\n",
|
||||
"\n",
|
||||
"# Historical Spills Analysis\n",
|
||||
"historical_report_delay_summary = historical_spills['Report Delay (Days)'].describe()\n",
|
||||
@@ -446,7 +449,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "spatial_env2",
|
||||
"display_name": "dadams",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -460,7 +463,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.15"
|
||||
"version": "3.11.8"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user