{ "cells": [ { "cell_type": "markdown", "id": "31fcb45e-dc0a-44d8-ac15-90d9788839be", "metadata": { "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "# Homework 2" ] }, { "cell_type": "code", "execution_count": 16, "id": "b8b3d4c7-5b9a-4726-b0e7-2c2ac6920ee0", "metadata": { "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{'Mean': 4578.118181818182,\n", " 'Median': 2542.2,\n", " 'Standard Deviation': 7122.264318774445,\n", " '25th percentile': 1565.425,\n", " '75th percentile': 4383.825000000001,\n", " 'IQR': 2818.4000000000005}" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd \n", "import numpy as np \n", "\n", "disasters = pd.read_csv(\"https://raw.githubusercontent.com/computationalUncertaintyLab/dexp_book/refs/heads/main/events-US-1980-2024.csv\")\n", "disasters = disasters.assign(Year = lambda x: x[\"End Date\"].astype(str).str[:3+1].astype(int) )\n", "disasters = disasters.loc[ disasters[\"Unadjusted Cost\"] !=\"TBD\" ]\n", "\n", "#--change these to floating values\n", "disasters[\"CPI-Adjusted Cost\"] = disasters[\"CPI-Adjusted Cost\"].astype(float)\n", "disasters[\"Unadjusted Cost\"] = disasters[\"Unadjusted Cost\"].astype(float)\n" ] }, { "cell_type": "markdown", "id": "9e01927e-6eda-4e89-aaee-7e7aec7c568c", "metadata": { "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "## Problem one \n", "\n", "The goal for this problem is to add columns to the \"disasters\" dataset above to make selecting specific types of disasters easier. Use the template code in the notes to add columns for: Floods, Cyclones, Hurricanes, Tornadoes, and Severe Storms." ] }, { "cell_type": "code", "execution_count": 13, "id": "57ca51b2-0121-484f-896d-f90826757d6f", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Name | \n", "Disaster | \n", "Begin Date | \n", "End Date | \n", "CPI-Adjusted Cost | \n", "Unadjusted Cost | \n", "Deaths | \n", "Year | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "Southern Severe Storms and Flooding (April 1980) | \n", "Flooding | \n", "19800410 | \n", "19800417 | \n", "2742.3 | \n", "706.8 | \n", "7 | \n", "1980 | \n", "
1 | \n", "Hurricane Allen (August 1980) | \n", "Tropical Cyclone | \n", "19800807 | \n", "19800811 | \n", "2230.2 | \n", "590 | \n", "13 | \n", "1980 | \n", "
2 | \n", "Central/Eastern Drought/Heat Wave (Summer-Fall... | \n", "Drought | \n", "19800601 | \n", "19801130 | \n", "40480.8 | \n", "10020 | \n", "1260 | \n", "1980 | \n", "
3 | \n", "Florida Freeze (January 1981) | \n", "Freeze | \n", "19810112 | \n", "19810114 | \n", "2070.6 | \n", "572 | \n", "0 | \n", "1981 | \n", "
4 | \n", "Severe Storms, Flash Floods, Hail, Tornadoes (... | \n", "Severe Storm | \n", "19810505 | \n", "19810510 | \n", "1405.2 | \n", "401.4 | \n", "20 | \n", "1981 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
395 | \n", "Hurricane Beryl (July 2024) | \n", "Tropical Cyclone | \n", "20240708 | \n", "20240708 | \n", "7219 | \n", "7219 | \n", "45 | \n", "2024 | \n", "
396 | \n", "Central and Eastern Tornado Outbreak and Sever... | \n", "Severe Storm | \n", "20240713 | \n", "20240716 | \n", "2435 | \n", "2435 | \n", "2 | \n", "2024 | \n", "
397 | \n", "Hurricane Debby (August 2024) | \n", "Tropical Cyclone | \n", "20240805 | \n", "20240809 | \n", "2476 | \n", "2476 | \n", "10 | \n", "2024 | \n", "
398 | \n", "Hurricane Helene (September 2024) | \n", "Tropical Cyclone | \n", "20240924 | \n", "20240929 | \n", "TBD | \n", "TBD | \n", "225 | \n", "2024 | \n", "
399 | \n", "Hurricane Milton (August 2024) | \n", "Tropical Cyclone | \n", "20241009 | \n", "20241010 | \n", "TBD | \n", "TBD | \n", "24 | \n", "2024 | \n", "
400 rows × 8 columns
\n", "