Damage due to natural disasters
Suppose you are given this dataset on storm events in 2019 from NOAA.
Using this data, you're asked to calculate the following:
- Total monetary damage in 2019
- Top 5 states in 2019 with highest monetary damage
- Plot the total monetary damage by month
The code below will help trim down the dataset so you can focus on a few columns. Below are descriptions for the included fields:
EVENT_ID: Unique ID for the storm event
STATE: State where the event occured
EVENT_TYPE: Type of storm event
BEGIN_DATE_TIME: The end time of the event. Format is MM/DD/YYYY 24 hour time AM/PM
BEGIN_YEARMONTH: The year and month of the event
DAMAGE_PROPERTY: The estimated amount of damage to property incurred by the weather event. For example, 10.00K = 10,000; 10.00M = 10,000,000. You will need to convert this field in order to successfully do the calculations listed above.
DAMAGE_CROPS: The estimated amount of damage to crops incurred by the weather event. For example, 10.00K = 10,000; 10.00M = 10,000,000. You will need to convert this field in order to successfully do the calculations listed above.
To help get you started, below is Python code that imports the data and only includes the fields needed to do the analysis. You can also view the code in this Google Colab notebook.
# Importing packages import pandas as pd import matplotlib.pyplot as plt import numpy as np # Reading in data df = pd.read_csv('https://www1.ncdc.noaa.gov/pub/data/swdi/stormevents/csvfiles/StormEvents_details-ftp_v1.0_d2019_c20200219.csv.gz', parse_dates=True) df = df[['EVENT_ID', 'STATE', 'EVENT_TYPE', 'CZ_TYPE', 'BEGIN_DATE_TIME', 'BEGIN_YEARMONTH', 'DAMAGE_PROPERTY', 'DAMAGE_CROPS' ]] df.head()
|0||824116||TEXAS||Flash Flood||C||09-MAY-19 15:54:00||201905||...|
|1||843354||MINNESOTA||Thunderstorm Wind||C||15-JUL-19 16:40:00||201907||...|
|2||861581||TEXAS||Thunderstorm Wind||C||20-OCT-19 22:23:00||201910||...|
|3||861584||TEXAS||Thunderstorm Wind||C||20-OCT-19 23:12:00||201910||...|
|4||861582||TEXAS||Thunderstorm Wind||C||20-OCT-19 22:36:00||201910||...|
Subscribe to premium account to see the solution.Get premium now