In [1]:
import pandas as pd
In [2]:
#DJF
Table = pd.read_csv('C:\Users\Ty Dickinson\Downloads\ClimoFlooding.csv', low_memory=False)
Table['BEGIN_DATE'] = pd.to_datetime(Table.BEGIN_DATE)
#adding new columns based on adjustments from existing columns
Table['Total_Damages'] = Table['DAMAGE_PROPERTY_NUM'] + Table['DAMAGE_CROPS_NUM']
Table['Z_Time'] = Table['BEGIN_TIME']
Table['Z_Day'] = Table['BEGIN_DATE']
pd.options.mode.chained_assignment = None
Table.DEATHS_DIRECT = Table.DEATHS_DIRECT.astype(int)
Table.INJURIES_DIRECT = Table.INJURIES_DIRECT.astype(int)
Table.BEGIN_TIME = Table.BEGIN_TIME.astype(int)
#converting CST to Z
for i in range(0, len(Table.BEGIN_TIME)):
if Table.BEGIN_TIME[i] <= 1759:
Table.Z_Time[i] = Table.BEGIN_TIME[i] + 600
Table.Z_Day[i] = Table.BEGIN_DATE[i]
else:
Table.Z_Time[i] = (Table.BEGIN_TIME[i] + 600) - 2400
Table.Z_Day[i] = Table.BEGIN_DATE[i] + pd.DateOffset(days=1)
#Defining lists to use for each indicator
DJFReports = []
DJFDeath = []
DJFInjury = []
DJFCost = []
DJFReportDaysList = []
#setting the index as date to use the df.loc expression
df = Table.set_index(['BEGIN_DATE'])
#defining date ranges and converting them to a Datetime data type
Date1 = pd.to_datetime('12-01-1980')
Date2 = pd.to_datetime('02-28-1981')
DJFCount = 0
#while statements to cycle through seasons and calculate reports, report days, fatalities, injuries,
#and damages
while DJFCount <= 29:
x = df.loc[Date1:Date2]
DJFReports.insert(DJFCount,len(x.index))
y = x.DEATHS_DIRECT.sum()
DJFDeath.insert(DJFCount,y)
z = x.INJURIES_DIRECT.sum()
DJFInjury.insert(DJFCount,z)
c = x.Total_Damages.sum()
DJFCost.insert(DJFCount,c)
DJFReportDays = 1
#nested if statements to calculate report days based on 12Z to 12Z the next day as 1 day
if len(x.index) == 0:
DJFReportDaysList.insert(DJFCount, 0)
else:
for i in range(1, len(x.index)):
if ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] < 1200))):
continue
elif ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] >= 1200) and (x.Z_Time[i-1] >= 1200))):
continue
elif (x.Z_Day[i] == (x.Z_Day[i-1] + pd.DateOffset(days=1))) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] >= 1200)):
continue
else:
DJFReportDays = DJFReportDays + 1
DJFReportDaysList.insert(DJFCount, DJFReportDays)
#if the year was a leap year, then this sets the end date back to Feb. 28
if Date2.is_leap_year:
Date2 = Date2 - pd.DateOffset(days=1)
#adds a year to the end date range for the next cycle of the while statement
Date1 = Date1 + pd.DateOffset(years=1)
Date2 = Date2 + pd.DateOffset(years=1)
#if the upcoming year is a leap year, add 1 day to account for Feb. 29
if Date2.is_leap_year:
Date2 = Date2 + pd.DateOffset(days=1)
DJFCount = DJFCount + 1
#Create dataframes for each list
DJFdf1 = pd.DataFrame({'DJF Reports': DJFReports})
DJFdf2 = pd.DataFrame({'DJF Report Days': DJFReportDaysList})
DJFdf3 = pd.DataFrame({'DJF Fatalities': DJFDeath})
DJFdf4 = pd.DataFrame({'DJF Injuries': DJFInjury})
DJFdf5 = pd.DataFrame({'DJF Damages': DJFCost})
#concatenate the dataframes together
DJFdftot = pd.concat([
DJFdf1, DJFdf2, DJFdf3, DJFdf4,
DJFdf5], axis=1)
years = []
for i in range(1981,2011):
years.insert(i,i)
DJFdftot = DJFdftot.set_index([years])
In [3]:
#JFM
Table = pd.read_csv('C:\Users\Ty Dickinson\Downloads\ClimoFlooding.csv', low_memory=False)
Table['BEGIN_DATE'] = pd.to_datetime(Table.BEGIN_DATE)
#adding new columns based on adjustments from existing columns
Table['Total_Damages'] = Table['DAMAGE_PROPERTY_NUM'] + Table['DAMAGE_CROPS_NUM']
Table['Z_Time'] = Table['BEGIN_TIME']
Table['Z_Day'] = Table['BEGIN_DATE']
pd.options.mode.chained_assignment = None
Table.DEATHS_DIRECT = Table.DEATHS_DIRECT.astype(int)
Table.INJURIES_DIRECT = Table.INJURIES_DIRECT.astype(int)
Table.BEGIN_TIME = Table.BEGIN_TIME.astype(int)
#converting CST to Z
for i in range(0, len(Table.BEGIN_TIME)):
if Table.BEGIN_TIME[i] <= 1759:
Table.Z_Time[i] = Table.BEGIN_TIME[i] + 600
Table.Z_Day[i] = Table.BEGIN_DATE[i]
else:
Table.Z_Time[i] = (Table.BEGIN_TIME[i] + 600) - 2400
Table.Z_Day[i] = Table.BEGIN_DATE[i] + pd.DateOffset(days=1)
#Defining lists to use for each indicator
JFMReports = []
JFMDeath = []
JFMInjury = []
JFMCost = []
JFMReportDaysList = []
#setting the index as date to use the df.loc expression
df = Table.set_index(['BEGIN_DATE'])
#defining date ranges and converting them to a Datetime data type
Date3 = pd.to_datetime('01-01-1981')
Date4 = pd.to_datetime('03-31-1981')
JFMCount = 0
#while statements to cycle through seasons and calculate reports, report days, fatalities, injuries,
#and damages
while JFMCount <= 29:
x = df.loc[Date3:Date4]
JFMReports.insert(JFMCount,len(x.index))
y = x.DEATHS_DIRECT.sum()
JFMDeath.insert(JFMCount,y)
z = x.INJURIES_DIRECT.sum()
JFMInjury.insert(JFMCount,z)
c = x.Total_Damages.sum()
JFMCost.insert(JFMCount,c)
JFMReportDays = 1
#nested if statements to calculate report days based on 12Z to 12Z the next day as 1 day
if len(x.index) == 0:
JFMReportDaysList.insert(JFMCount, 0)
else:
for i in range(1, len(x.index)):
if ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] < 1200))):
continue
elif ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] >= 1200) and (x.Z_Time[i-1] >= 1200))):
continue
elif (x.Z_Day[i] == (x.Z_Day[i-1] + pd.DateOffset(days=1))) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] >= 1200)):
continue
else:
JFMReportDays = JFMReportDays + 1
JFMReportDaysList.insert(JFMCount, JFMReportDays)
Date3 = Date3 + pd.DateOffset(years=1)
Date4 = Date4 + pd.DateOffset(years=1)
JFMCount = JFMCount + 1
#Create dataframes for each list
JFMdf1 = pd.DataFrame({'JFM Reports': JFMReports})
JFMdf2 = pd.DataFrame({'JFM Report Days': JFMReportDaysList})
JFMdf3 = pd.DataFrame({'JFM Fatalities': JFMDeath})
JFMdf4 = pd.DataFrame({'JFM Injuries': JFMInjury})
JFMdf5 = pd.DataFrame({'JFM Damages': JFMCost})
#concatenate the dataframes together
JFMdftot = pd.concat([
JFMdf1, JFMdf2, JFMdf3, JFMdf4,
JFMdf5], axis=1)
years = []
for i in range(1981,2011):
years.insert(i,i)
JFMdftot = JFMdftot.set_index([years])
In [4]:
#FMA
Table = pd.read_csv('C:\Users\Ty Dickinson\Downloads\ClimoFlooding.csv', low_memory=False)
Table['BEGIN_DATE'] = pd.to_datetime(Table.BEGIN_DATE)
#adding new columns based on adjustments from existing columns
Table['Total_Damages'] = Table['DAMAGE_PROPERTY_NUM'] + Table['DAMAGE_CROPS_NUM']
Table['Z_Time'] = Table['BEGIN_TIME']
Table['Z_Day'] = Table['BEGIN_DATE']
pd.options.mode.chained_assignment = None
Table.DEATHS_DIRECT = Table.DEATHS_DIRECT.astype(int)
Table.INJURIES_DIRECT = Table.INJURIES_DIRECT.astype(int)
Table.BEGIN_TIME = Table.BEGIN_TIME.astype(int)
#converting CST to Z
for i in range(0, len(Table.BEGIN_TIME)):
if Table.BEGIN_TIME[i] <= 1759:
Table.Z_Time[i] = Table.BEGIN_TIME[i] + 600
Table.Z_Day[i] = Table.BEGIN_DATE[i]
else:
Table.Z_Time[i] = (Table.BEGIN_TIME[i] + 600) - 2400
Table.Z_Day[i] = Table.BEGIN_DATE[i] + pd.DateOffset(days=1)
#Defining lists to use for each indicator
FMAReports = []
FMADeath = []
FMAInjury = []
FMACost = []
FMAReportDaysList = []
#setting the index as date to use the df.loc expression
df = Table.set_index(['BEGIN_DATE'])
#defining date ranges and converting them to a Datetime data type
Date5 = pd.to_datetime('02-01-1981')
Date6 = pd.to_datetime('04-30-1981')
FMACount = 0
#while statements to cycle through seasons and calculate reports, report days, fatalities, injuries,
#and damages
while FMACount <= 29:
x = df.loc[Date5:Date6]
FMAReports.insert(FMACount,len(x.index))
y = x.DEATHS_DIRECT.sum()
FMADeath.insert(FMACount,y)
z = x.INJURIES_DIRECT.sum()
FMAInjury.insert(FMACount,z)
c = x.Total_Damages.sum()
FMACost.insert(FMACount,c)
FMAReportDays = 1
#nested if statements to calculate report days based on 12Z to 12Z the next day as 1 day
if len(x.index) == 0:
FMAReportDaysList.insert(FMACount, 0)
else:
for i in range(1, len(x.index)):
if ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] < 1200))):
continue
elif ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] >= 1200) and (x.Z_Time[i-1] >= 1200))):
continue
elif (x.Z_Day[i] == (x.Z_Day[i-1] + pd.DateOffset(days=1))) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] >= 1200)):
continue
else:
FMAReportDays = FMAReportDays + 1
FMAReportDaysList.insert(FMACount, FMAReportDays)
Date5 = Date5 + pd.DateOffset(years=1)
Date6 = Date6 + pd.DateOffset(years=1)
FMACount = FMACount + 1
#Create dataframes for each list
FMAdf1 = pd.DataFrame({'FMA Reports': FMAReports})
FMAdf2 = pd.DataFrame({'FMA Report Days': FMAReportDaysList})
FMAdf3 = pd.DataFrame({'FMA Fatalities': FMADeath})
FMAdf4 = pd.DataFrame({'FMA Injuries': FMAInjury})
FMAdf5 = pd.DataFrame({'FMA Damages': FMACost})
#concatenate the dataframes together
FMAdftot = pd.concat([
FMAdf1, FMAdf2, FMAdf3, FMAdf4,
FMAdf5], axis=1)
years = []
for i in range(1981,2011):
years.insert(i,i)
FMAdftot = FMAdftot.set_index([years])
In [5]:
#MAM
Table = pd.read_csv('C:\Users\Ty Dickinson\Downloads\ClimoFlooding.csv', low_memory=False)
Table['BEGIN_DATE'] = pd.to_datetime(Table.BEGIN_DATE)
#adding new columns based on adjustments from existing columns
Table['Total_Damages'] = Table['DAMAGE_PROPERTY_NUM'] + Table['DAMAGE_CROPS_NUM']
Table['Z_Time'] = Table['BEGIN_TIME']
Table['Z_Day'] = Table['BEGIN_DATE']
pd.options.mode.chained_assignment = None
Table.DEATHS_DIRECT = Table.DEATHS_DIRECT.astype(int)
Table.INJURIES_DIRECT = Table.INJURIES_DIRECT.astype(int)
Table.BEGIN_TIME = Table.BEGIN_TIME.astype(int)
#converting CST to Z
for i in range(0, len(Table.BEGIN_TIME)):
if Table.BEGIN_TIME[i] <= 1759:
Table.Z_Time[i] = Table.BEGIN_TIME[i] + 600
Table.Z_Day[i] = Table.BEGIN_DATE[i]
else:
Table.Z_Time[i] = (Table.BEGIN_TIME[i] + 600) - 2400
Table.Z_Day[i] = Table.BEGIN_DATE[i] + pd.DateOffset(days=1)
#Defining lists to use for each indicator
MAMReports = []
MAMDeath = []
MAMInjury = []
MAMCost = []
MAMReportDaysList = []
#setting the index as date to use the df.loc expression
df = Table.set_index(['BEGIN_DATE'])
#defining date ranges and converting them to a Datetime data type
Date7 = pd.to_datetime('03-01-1981')
Date8 = pd.to_datetime('05-31-1981')
MAMCount = 0
#while statements to cycle through seasons and calculate reports, report days, fatalities, injuries,
#and damages
while MAMCount <= 29:
x = df.loc[Date7:Date8]
MAMReports.insert(MAMCount,len(x.index))
y = x.DEATHS_DIRECT.sum()
MAMDeath.insert(MAMCount,y)
z = x.INJURIES_DIRECT.sum()
MAMInjury.insert(MAMCount,z)
c = x.Total_Damages.sum()
MAMCost.insert(MAMCount,c)
MAMReportDays = 1
#nested if statements to calculate report days based on 12Z to 12Z the next day as 1 day
if len(x.index) == 0:
MAMReportDaysList.insert(MAMCount, 0)
else:
for i in range(1, len(x.index)):
if ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] < 1200))):
continue
elif ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] >= 1200) and (x.Z_Time[i-1] >= 1200))):
continue
elif (x.Z_Day[i] == (x.Z_Day[i-1] + pd.DateOffset(days=1))) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] >= 1200)):
continue
else:
MAMReportDays = MAMReportDays + 1
MAMReportDaysList.insert(MAMCount, MAMReportDays)
Date7 = Date7 + pd.DateOffset(years=1)
Date8 = Date8 + pd.DateOffset(years=1)
MAMCount = MAMCount + 1
#Create dataframes for each list
MAMdf1 = pd.DataFrame({'MAM Reports': MAMReports})
MAMdf2 = pd.DataFrame({'MAM Report Days': MAMReportDaysList})
MAMdf3 = pd.DataFrame({'MAM Fatalities': MAMDeath})
MAMdf4 = pd.DataFrame({'MAM Injuries': MAMInjury})
MAMdf5 = pd.DataFrame({'MAM Damages': MAMCost})
#concatenate the dataframes together
MAMdftot = pd.concat([
MAMdf1, MAMdf2, MAMdf3, MAMdf4,
MAMdf5], axis=1)
years = []
for i in range(1981,2011):
years.insert(i,i)
MAMdftot = MAMdftot.set_index([years])
In [6]:
#AMJ
Table = pd.read_csv('C:\Users\Ty Dickinson\Downloads\ClimoFlooding.csv', low_memory=False)
Table['BEGIN_DATE'] = pd.to_datetime(Table.BEGIN_DATE)
#adding new columns based on adjustments from existing columns
Table['Total_Damages'] = Table['DAMAGE_PROPERTY_NUM'] + Table['DAMAGE_CROPS_NUM']
Table['Z_Time'] = Table['BEGIN_TIME']
Table['Z_Day'] = Table['BEGIN_DATE']
pd.options.mode.chained_assignment = None
Table.DEATHS_DIRECT = Table.DEATHS_DIRECT.astype(int)
Table.INJURIES_DIRECT = Table.INJURIES_DIRECT.astype(int)
Table.BEGIN_TIME = Table.BEGIN_TIME.astype(int)
#converting CST to Z
for i in range(0, len(Table.BEGIN_TIME)):
if Table.BEGIN_TIME[i] <= 1759:
Table.Z_Time[i] = Table.BEGIN_TIME[i] + 600
Table.Z_Day[i] = Table.BEGIN_DATE[i]
else:
Table.Z_Time[i] = (Table.BEGIN_TIME[i] + 600) - 2400
Table.Z_Day[i] = Table.BEGIN_DATE[i] + pd.DateOffset(days=1)
#Defining lists to use for each indicator
AMJReports = []
AMJDeath = []
AMJInjury = []
AMJCost = []
AMJReportDaysList = []
#setting the index as date to use the df.loc expression
df = Table.set_index(['BEGIN_DATE'])
#defining date ranges and converting them to a Datetime data type
Date9 = pd.to_datetime('04-01-1981')
Date10 = pd.to_datetime('06-30-1981')
AMJCount = 0
#while statements to cycle through seasons and calculate reports, report days, fatalities, injuries,
#and damages
while AMJCount <= 29:
x = df.loc[Date9:Date10]
AMJReports.insert(AMJCount,len(x.index))
y = x.DEATHS_DIRECT.sum()
AMJDeath.insert(AMJCount,y)
z = x.INJURIES_DIRECT.sum()
AMJInjury.insert(AMJCount,z)
c = x.Total_Damages.sum()
AMJCost.insert(AMJCount,c)
AMJReportDays = 1
#nested if statements to calculate report days based on 12Z to 12Z the next day as 1 day
if len(x.index) == 0:
AMJReportDaysList.insert(AMJCount, 0)
else:
for i in range(1, len(x.index)):
if ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] < 1200))):
continue
elif ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] >= 1200) and (x.Z_Time[i-1] >= 1200))):
continue
elif (x.Z_Day[i] == (x.Z_Day[i-1] + pd.DateOffset(days=1))) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] >= 1200)):
continue
else:
AMJReportDays = AMJReportDays + 1
AMJReportDaysList.insert(AMJCount, AMJReportDays)
Date9 = Date9 + pd.DateOffset(years=1)
Date10 = Date10 + pd.DateOffset(years=1)
AMJCount = AMJCount + 1
#Create dataframes for each list
AMJdf1 = pd.DataFrame({'AMJ Reports': AMJReports})
AMJdf2 = pd.DataFrame({'AMJ Report Days': AMJReportDaysList})
AMJdf3 = pd.DataFrame({'AMJ Fatalities': AMJDeath})
AMJdf4 = pd.DataFrame({'AMJ Injuries': AMJInjury})
AMJdf5 = pd.DataFrame({'AMJ Damages': AMJCost})
#concatenate the dataframes together
AMJdftot = pd.concat([
AMJdf1, AMJdf2, AMJdf3, AMJdf4,
AMJdf5], axis=1)
years = []
for i in range(1981,2011):
years.insert(i,i)
AMJdftot = AMJdftot.set_index([years])
In [7]:
#MJJ
Table = pd.read_csv('C:\Users\Ty Dickinson\Downloads\ClimoFlooding.csv', low_memory=False)
Table['BEGIN_DATE'] = pd.to_datetime(Table.BEGIN_DATE)
#adding new columns based on adjustments from existing columns
Table['Total_Damages'] = Table['DAMAGE_PROPERTY_NUM'] + Table['DAMAGE_CROPS_NUM']
Table['Z_Time'] = Table['BEGIN_TIME']
Table['Z_Day'] = Table['BEGIN_DATE']
pd.options.mode.chained_assignment = None
Table.DEATHS_DIRECT = Table.DEATHS_DIRECT.astype(int)
Table.INJURIES_DIRECT = Table.INJURIES_DIRECT.astype(int)
Table.BEGIN_TIME = Table.BEGIN_TIME.astype(int)
#converting CST to Z
for i in range(0, len(Table.BEGIN_TIME)):
if Table.BEGIN_TIME[i] <= 1759:
Table.Z_Time[i] = Table.BEGIN_TIME[i] + 600
Table.Z_Day[i] = Table.BEGIN_DATE[i]
else:
Table.Z_Time[i] = (Table.BEGIN_TIME[i] + 600) - 2400
Table.Z_Day[i] = Table.BEGIN_DATE[i] + pd.DateOffset(days=1)
#Defining lists to use for each indicator
MJJReports = []
MJJDeath = []
MJJInjury = []
MJJCost = []
MJJReportDaysList = []
#setting the index as date to use the df.loc expression
df = Table.set_index(['BEGIN_DATE'])
#defining date ranges and converting them to a Datetime data type
Date11 = pd.to_datetime('05-01-1981')
Date12 = pd.to_datetime('07-31-1981')
MJJCount = 0
#while statements to cycle through seasons and calculate reports, report days, fatalities, injuries,
#and damages
while MJJCount <= 29:
x = df.loc[Date11:Date12]
MJJReports.insert(MJJCount,len(x.index))
y = x.DEATHS_DIRECT.sum()
MJJDeath.insert(MJJCount,y)
z = x.INJURIES_DIRECT.sum()
MJJInjury.insert(MJJCount,z)
c = x.Total_Damages.sum()
MJJCost.insert(MJJCount,c)
MJJReportDays = 1
#nested if statements to calculate report days based on 12Z to 12Z the next day as 1 day
if len(x.index) == 0:
MJJReportDaysList.insert(MJJCount, 0)
else:
for i in range(1, len(x.index)):
if ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] < 1200))):
continue
elif ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] >= 1200) and (x.Z_Time[i-1] >= 1200))):
continue
elif (x.Z_Day[i] == (x.Z_Day[i-1] + pd.DateOffset(days=1))) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] >= 1200)):
continue
else:
MJJReportDays = MJJReportDays + 1
MJJReportDaysList.insert(MJJCount, MJJReportDays)
Date11 = Date11 + pd.DateOffset(years=1)
Date12 = Date12 + pd.DateOffset(years=1)
MJJCount = MJJCount + 1
#Create dataframes for each list
MJJdf1 = pd.DataFrame({'MJJ Reports': MJJReports})
MJJdf2 = pd.DataFrame({'MJJ Report Days': MJJReportDaysList})
MJJdf3 = pd.DataFrame({'MJJ Fatalities': MJJDeath})
MJJdf4 = pd.DataFrame({'MJJ Injuries': MJJInjury})
MJJdf5 = pd.DataFrame({'MJJ Damages': MJJCost})
#concatenate the dataframes together
MJJdftot = pd.concat([
MJJdf1, MJJdf2, MJJdf3, MJJdf4,
MJJdf5], axis=1)
years = []
for i in range(1981,2011):
years.insert(i,i)
MJJdftot = MJJdftot.set_index([years])
In [8]:
#JJA
Table = pd.read_csv('C:\Users\Ty Dickinson\Downloads\ClimoFlooding.csv', low_memory=False)
Table['BEGIN_DATE'] = pd.to_datetime(Table.BEGIN_DATE)
#adding new columns based on adjustments from existing columns
Table['Total_Damages'] = Table['DAMAGE_PROPERTY_NUM'] + Table['DAMAGE_CROPS_NUM']
Table['Z_Time'] = Table['BEGIN_TIME']
Table['Z_Day'] = Table['BEGIN_DATE']
pd.options.mode.chained_assignment = None
Table.DEATHS_DIRECT = Table.DEATHS_DIRECT.astype(int)
Table.INJURIES_DIRECT = Table.INJURIES_DIRECT.astype(int)
Table.BEGIN_TIME = Table.BEGIN_TIME.astype(int)
#converting CST to Z
for i in range(0, len(Table.BEGIN_TIME)):
if Table.BEGIN_TIME[i] <= 1759:
Table.Z_Time[i] = Table.BEGIN_TIME[i] + 600
Table.Z_Day[i] = Table.BEGIN_DATE[i]
else:
Table.Z_Time[i] = (Table.BEGIN_TIME[i] + 600) - 2400
Table.Z_Day[i] = Table.BEGIN_DATE[i] + pd.DateOffset(days=1)
#Defining lists to use for each indicator
JJAReports = []
JJADeath = []
JJAInjury = []
JJACost = []
JJAReportDaysList = []
#setting the index as date to use the df.loc expression
df = Table.set_index(['BEGIN_DATE'])
#defining date ranges and converting them to a Datetime data type
Date13 = pd.to_datetime('06-01-1981')
Date14 = pd.to_datetime('08-31-1981')
JJACount = 0
#while statements to cycle through seasons and calculate reports, report days, fatalities, injuries,
#and damages
while JJACount <= 29:
x = df.loc[Date13:Date14]
JJAReports.insert(JJACount,len(x.index))
y = x.DEATHS_DIRECT.sum()
JJADeath.insert(JJACount,y)
z = x.INJURIES_DIRECT.sum()
JJAInjury.insert(JJACount,z)
c = x.Total_Damages.sum()
JJACost.insert(JJACount,c)
JJAReportDays = 1
#nested if statements to calculate report days based on 12Z to 12Z the next day as 1 day
if len(x.index) == 0:
JJAReportDaysList.insert(JJACount, 0)
else:
for i in range(1, len(x.index)):
if ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] < 1200))):
continue
elif ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] >= 1200) and (x.Z_Time[i-1] >= 1200))):
continue
elif (x.Z_Day[i] == (x.Z_Day[i-1] + pd.DateOffset(days=1))) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] >= 1200)):
continue
else:
JJAReportDays = JJAReportDays + 1
JJAReportDaysList.insert(JJACount, JJAReportDays)
Date13 = Date13 + pd.DateOffset(years=1)
Date14 = Date14 + pd.DateOffset(years=1)
JJACount = JJACount + 1
#Create dataframes for each list
JJAdf1 = pd.DataFrame({'JJA Reports': JJAReports})
JJAdf2 = pd.DataFrame({'JJA Report Days': JJAReportDaysList})
JJAdf3 = pd.DataFrame({'JJA Fatalities': JJADeath})
JJAdf4 = pd.DataFrame({'JJA Injuries': JJAInjury})
JJAdf5 = pd.DataFrame({'JJA Damages': JJACost})
#concatenate the dataframes together
JJAdftot = pd.concat([
JJAdf1, JJAdf2, JJAdf3, JJAdf4,
JJAdf5], axis=1)
years = []
for i in range(1981,2011):
years.insert(i,i)
JJAdftot = JJAdftot.set_index([years])
In [9]:
#JAS
Table = pd.read_csv('C:\Users\Ty Dickinson\Downloads\ClimoFlooding.csv', low_memory=False)
Table['BEGIN_DATE'] = pd.to_datetime(Table.BEGIN_DATE)
#adding new columns based on adjustments from existing columns
Table['Total_Damages'] = Table['DAMAGE_PROPERTY_NUM'] + Table['DAMAGE_CROPS_NUM']
Table['Z_Time'] = Table['BEGIN_TIME']
Table['Z_Day'] = Table['BEGIN_DATE']
pd.options.mode.chained_assignment = None
Table.DEATHS_DIRECT = Table.DEATHS_DIRECT.astype(int)
Table.INJURIES_DIRECT = Table.INJURIES_DIRECT.astype(int)
Table.BEGIN_TIME = Table.BEGIN_TIME.astype(int)
#converting CST to Z
for i in range(0, len(Table.BEGIN_TIME)):
if Table.BEGIN_TIME[i] <= 1759:
Table.Z_Time[i] = Table.BEGIN_TIME[i] + 600
Table.Z_Day[i] = Table.BEGIN_DATE[i]
else:
Table.Z_Time[i] = (Table.BEGIN_TIME[i] + 600) - 2400
Table.Z_Day[i] = Table.BEGIN_DATE[i] + pd.DateOffset(days=1)
#Defining lists to use for each indicator
JASReports = []
JASDeath = []
JASInjury = []
JASCost = []
JASReportDaysList = []
#setting the index as date to use the df.loc expression
df = Table.set_index(['BEGIN_DATE'])
#defining date ranges and converting them to a Datetime data type
Date15 = pd.to_datetime('07-01-1981')
Date16 = pd.to_datetime('09-30-1981')
JASCount = 0
#while statements to cycle through seasons and calculate reports, report days, fatalities, injuries
#damages, maximum hail size, maximum wind magnitude, maximum tornado width, and total tornado path length
while JASCount <= 29:
x = df.loc[Date15:Date16]
JASReports.insert(JASCount,len(x.index))
y = x.DEATHS_DIRECT.sum()
JASDeath.insert(JASCount,y)
z = x.INJURIES_DIRECT.sum()
JASInjury.insert(JASCount,z)
c = x.Total_Damages.sum()
JASCost.insert(JASCount,c)
JASReportDays = 1
#nested if statements to calculate report days based on 12Z to 12Z the next day as 1 day
if len(x.index) == 0:
JASReportDaysList.insert(JASCount, 0)
else:
for i in range(1, len(x.index)):
if ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] < 1200))):
continue
elif ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] >= 1200) and (x.Z_Time[i-1] >= 1200))):
continue
elif (x.Z_Day[i] == (x.Z_Day[i-1] + pd.DateOffset(days=1))) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] >= 1200)):
continue
else:
JASReportDays = JASReportDays + 1
JASReportDaysList.insert(JASCount, JASReportDays)
Date15 = Date15 + pd.DateOffset(years=1)
Date16 = Date16 + pd.DateOffset(years=1)
JASCount = JASCount + 1
#Create dataframes for each list
JASdf1 = pd.DataFrame({'JAS Reports': JASReports})
JASdf2 = pd.DataFrame({'JAS Report Days': JASReportDaysList})
JASdf3 = pd.DataFrame({'JAS Fatalities': JASDeath})
JASdf4 = pd.DataFrame({'JAS Injuries': JASInjury})
JASdf5 = pd.DataFrame({'JAS Damages': JASCost})
#concatenate the dataframes together
JASdftot = pd.concat([
JASdf1, JASdf2, JASdf3, JASdf4,
JASdf5], axis=1)
years = []
for i in range(1981,2011):
years.insert(i,i)
JASdftot = JASdftot.set_index([years])
In [10]:
#ASO
Table = pd.read_csv('C:\Users\Ty Dickinson\Downloads\ClimoFlooding.csv', low_memory=False)
Table['BEGIN_DATE'] = pd.to_datetime(Table.BEGIN_DATE)
#adding new columns based on adjustments from existing columns
Table['Total_Damages'] = Table['DAMAGE_PROPERTY_NUM'] + Table['DAMAGE_CROPS_NUM']
Table['Z_Time'] = Table['BEGIN_TIME']
Table['Z_Day'] = Table['BEGIN_DATE']
pd.options.mode.chained_assignment = None
Table.DEATHS_DIRECT = Table.DEATHS_DIRECT.astype(int)
Table.INJURIES_DIRECT = Table.INJURIES_DIRECT.astype(int)
Table.BEGIN_TIME = Table.BEGIN_TIME.astype(int)
#converting CST to Z
for i in range(0, len(Table.BEGIN_TIME)):
if Table.BEGIN_TIME[i] <= 1759:
Table.Z_Time[i] = Table.BEGIN_TIME[i] + 600
Table.Z_Day[i] = Table.BEGIN_DATE[i]
else:
Table.Z_Time[i] = (Table.BEGIN_TIME[i] + 600) - 2400
Table.Z_Day[i] = Table.BEGIN_DATE[i] + pd.DateOffset(days=1)
#Defining lists to use for each indicator
ASOReports = []
ASODeath = []
ASOInjury = []
ASOCost = []
ASOReportDaysList = []
#setting the index as date to use the df.loc expression
df = Table.set_index(['BEGIN_DATE'])
#defining date ranges and converting them to a Datetime data type
Date17 = pd.to_datetime('08-01-1981')
Date18 = pd.to_datetime('10-31-1981')
ASOCount = 0
#while statements to cycle through seasons and calculate reports, report days, fatalities, injuries
#damages, maximum hail size, maximum wind magnitude, maximum tornado width, and total tornado path length
while ASOCount <= 29:
x = df.loc[Date17:Date18]
ASOReports.insert(ASOCount,len(x.index))
y = x.DEATHS_DIRECT.sum()
ASODeath.insert(ASOCount,y)
z = x.INJURIES_DIRECT.sum()
ASOInjury.insert(ASOCount,z)
c = x.Total_Damages.sum()
ASOCost.insert(ASOCount,c)
ASOReportDays = 1
#nested if statements to calculate report days based on 12Z to 12Z the next day as 1 day
if len(x.index) == 0:
ASOReportDaysList.insert(ASOCount, 0)
else:
for i in range(1, len(x.index)):
if ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] < 1200))):
continue
elif ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] >= 1200) and (x.Z_Time[i-1] >= 1200))):
continue
elif (x.Z_Day[i] == (x.Z_Day[i-1] + pd.DateOffset(days=1))) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] >= 1200)):
continue
else:
ASOReportDays = ASOReportDays + 1
ASOReportDaysList.insert(ASOCount, ASOReportDays)
Date17 = Date17 + pd.DateOffset(years=1)
Date18 = Date18 + pd.DateOffset(years=1)
ASOCount = ASOCount + 1
#Create dataframes for each list
ASOdf1 = pd.DataFrame({'ASO Reports': ASOReports})
ASOdf2 = pd.DataFrame({'ASO Report Days': ASOReportDaysList})
ASOdf3 = pd.DataFrame({'ASO Fatalities': ASODeath})
ASOdf4 = pd.DataFrame({'ASO Injuries': ASOInjury})
ASOdf5 = pd.DataFrame({'ASO Damages': ASOCost})
#concatenate the dataframes together
ASOdftot = pd.concat([
ASOdf1, ASOdf2, ASOdf3, ASOdf4,
ASOdf5], axis=1)
years = []
for i in range(1981,2011):
years.insert(i,i)
ASOdftot = ASOdftot.set_index([years])
In [11]:
#SON
Table = pd.read_csv('C:\Users\Ty Dickinson\Downloads\ClimoFlooding.csv', low_memory=False)
Table['BEGIN_DATE'] = pd.to_datetime(Table.BEGIN_DATE)
#adding new columns based on adjustments from existing columns
Table['Total_Damages'] = Table['DAMAGE_PROPERTY_NUM'] + Table['DAMAGE_CROPS_NUM']
Table['Z_Time'] = Table['BEGIN_TIME']
Table['Z_Day'] = Table['BEGIN_DATE']
pd.options.mode.chained_assignment = None
Table.DEATHS_DIRECT = Table.DEATHS_DIRECT.astype(int)
Table.INJURIES_DIRECT = Table.INJURIES_DIRECT.astype(int)
Table.BEGIN_TIME = Table.BEGIN_TIME.astype(int)
#converting CST to Z
for i in range(0, len(Table.BEGIN_TIME)):
if Table.BEGIN_TIME[i] <= 1759:
Table.Z_Time[i] = Table.BEGIN_TIME[i] + 600
Table.Z_Day[i] = Table.BEGIN_DATE[i]
else:
Table.Z_Time[i] = (Table.BEGIN_TIME[i] + 600) - 2400
Table.Z_Day[i] = Table.BEGIN_DATE[i] + pd.DateOffset(days=1)
#Defining lists to use for each indicator
SONReports = []
SONDeath = []
SONInjury = []
SONCost = []
SONReportDaysList = []
#setting the index as date to use the df.loc expression
df = Table.set_index(['BEGIN_DATE'])
#defining date ranges and converting them to a Datetime data type
Date19 = pd.to_datetime('09-01-1981')
Date20 = pd.to_datetime('11-30-1981')
SONCount = 0
#while statements to cycle through seasons and calculate reports, report days, fatalities, injuries
#damages, maximum hail size, maximum wind magnitude, maximum tornado width, and total tornado path length
while SONCount <= 29:
x = df.loc[Date19:Date20]
SONReports.insert(SONCount,len(x.index))
y = x.DEATHS_DIRECT.sum()
SONDeath.insert(SONCount,y)
z = x.INJURIES_DIRECT.sum()
SONInjury.insert(SONCount,z)
c = x.Total_Damages.sum()
SONCost.insert(SONCount,c)
SONReportDays = 1
#nested if statements to calculate report days based on 12Z to 12Z the next day as 1 day
if len(x.index) == 0:
SONReportDaysList.insert(SONCount, 0)
else:
for i in range(1, len(x.index)):
if ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] < 1200))):
continue
elif ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] >= 1200) and (x.Z_Time[i-1] >= 1200))):
continue
elif (x.Z_Day[i] == (x.Z_Day[i-1] + pd.DateOffset(days=1))) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] >= 1200)):
continue
else:
SONReportDays = SONReportDays + 1
SONReportDaysList.insert(SONCount, SONReportDays)
Date19 = Date19 + pd.DateOffset(years=1)
Date20 = Date20 + pd.DateOffset(years=1)
SONCount = SONCount + 1
#Create dataframes for each list
SONdf1 = pd.DataFrame({'SON Reports': SONReports})
SONdf2 = pd.DataFrame({'SON Report Days': SONReportDaysList})
SONdf3 = pd.DataFrame({'SON Fatalities': SONDeath})
SONdf4 = pd.DataFrame({'SON Injuries': SONInjury})
SONdf5 = pd.DataFrame({'SON Damages': SONCost})
#concatenate the dataframes together
SONdftot = pd.concat([
SONdf1, SONdf2, SONdf3, SONdf4,
SONdf5], axis=1)
years = []
for i in range(1981,2011):
years.insert(i,i)
SONdftot = SONdftot.set_index([years])
In [12]:
#OND
Table = pd.read_csv('C:\Users\Ty Dickinson\Downloads\ClimoFlooding.csv', low_memory=False)
Table['BEGIN_DATE'] = pd.to_datetime(Table.BEGIN_DATE)
#adding new columns based on adjustments from existing columns
Table['Total_Damages'] = Table['DAMAGE_PROPERTY_NUM'] + Table['DAMAGE_CROPS_NUM']
Table['Z_Time'] = Table['BEGIN_TIME']
Table['Z_Day'] = Table['BEGIN_DATE']
pd.options.mode.chained_assignment = None
Table.DEATHS_DIRECT = Table.DEATHS_DIRECT.astype(int)
Table.INJURIES_DIRECT = Table.INJURIES_DIRECT.astype(int)
Table.BEGIN_TIME = Table.BEGIN_TIME.astype(int)
#converting CST to Z
for i in range(0, len(Table.BEGIN_TIME)):
if Table.BEGIN_TIME[i] <= 1759:
Table.Z_Time[i] = Table.BEGIN_TIME[i] + 600
Table.Z_Day[i] = Table.BEGIN_DATE[i]
else:
Table.Z_Time[i] = (Table.BEGIN_TIME[i] + 600) - 2400
Table.Z_Day[i] = Table.BEGIN_DATE[i] + pd.DateOffset(days=1)
#Defining lists to use for each indicator
ONDReports = []
ONDDeath = []
ONDInjury = []
ONDCost = []
ONDReportDaysList = []
#setting the index as date to use the df.loc expression
df = Table.set_index(['BEGIN_DATE'])
#defining date ranges and converting them to a Datetime data type
Date21 = pd.to_datetime('10-01-1981')
Date22 = pd.to_datetime('12-31-1981')
ONDCount = 0
#while statements to cycle through seasons and calculate reports, report days, fatalities, injuries
#damages, maximum hail size, maximum wind magnitude, maximum tornado width, and total tornado path length
while ONDCount <= 29:
x = df.loc[Date21:Date22]
ONDReports.insert(ONDCount,len(x.index))
y = x.DEATHS_DIRECT.sum()
ONDDeath.insert(ONDCount,y)
z = x.INJURIES_DIRECT.sum()
ONDInjury.insert(ONDCount,z)
c = x.Total_Damages.sum()
ONDCost.insert(ONDCount,c)
ONDReportDays = 1
#nested if statements to calculate report days based on 12Z to 12Z the next day as 1 day
if len(x.index) == 0:
ONDReportDaysList.insert(ONDCount, 0)
else:
for i in range(1, len(x.index)):
if ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] < 1200))):
continue
elif ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] >= 1200) and (x.Z_Time[i-1] >= 1200))):
continue
elif (x.Z_Day[i] == (x.Z_Day[i-1] + pd.DateOffset(days=1))) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] >= 1200)):
continue
else:
ONDReportDays = ONDReportDays + 1
ONDReportDaysList.insert(ONDCount, ONDReportDays)
Date21 = Date21 + pd.DateOffset(years=1)
Date22 = Date22 + pd.DateOffset(years=1)
ONDCount = ONDCount + 1
#Create dataframes for each list
ONDdf1 = pd.DataFrame({'OND Reports': ONDReports})
ONDdf2 = pd.DataFrame({'OND Report Days': ONDReportDaysList})
ONDdf3 = pd.DataFrame({'OND Fatalities': ONDDeath})
ONDdf4 = pd.DataFrame({'OND Injuries': ONDInjury})
ONDdf5 = pd.DataFrame({'OND Damages': ONDCost})
#concatenate the dataframes together
ONDdftot = pd.concat([
ONDdf1, ONDdf2, ONDdf3, ONDdf4,
ONDdf5], axis=1)
years = []
for i in range(1981,2011):
years.insert(i,i)
ONDdftot = ONDdftot.set_index([years])
In [13]:
#NDJ
Table = pd.read_csv('C:\Users\Ty Dickinson\Downloads\ClimoFlooding.csv', low_memory=False)
Table['BEGIN_DATE'] = pd.to_datetime(Table.BEGIN_DATE)
#adding new columns based on adjustments from existing columns
Table['Total_Damages'] = Table['DAMAGE_PROPERTY_NUM'] + Table['DAMAGE_CROPS_NUM']
Table['Z_Time'] = Table['BEGIN_TIME']
Table['Z_Day'] = Table['BEGIN_DATE']
pd.options.mode.chained_assignment = None
Table.DEATHS_DIRECT = Table.DEATHS_DIRECT.astype(int)
Table.INJURIES_DIRECT = Table.INJURIES_DIRECT.astype(int)
Table.BEGIN_TIME = Table.BEGIN_TIME.astype(int)
#converting CST to Z
for i in range(0, len(Table.BEGIN_TIME)):
if Table.BEGIN_TIME[i] <= 1759:
Table.Z_Time[i] = Table.BEGIN_TIME[i] + 600
Table.Z_Day[i] = Table.BEGIN_DATE[i]
else:
Table.Z_Time[i] = (Table.BEGIN_TIME[i] + 600) - 2400
Table.Z_Day[i] = Table.BEGIN_DATE[i] + pd.DateOffset(days=1)
#Defining lists to use for each indicator
NDJReports = []
NDJDeath = []
NDJInjury = []
NDJCost = []
NDJReportDaysList = []
#setting the index as date to use the df.loc expression
df = Table.set_index(['BEGIN_DATE'])
#defining date ranges and converting them to a Datetime data type
Date23 = pd.to_datetime('11-01-1981')
Date24 = pd.to_datetime('01-31-1982')
NDJCount = 0
#while statements to cycle through seasons and calculate reports, report days, fatalities, injuries
#damages, maximum hail size, maximum wind magnitude, maximum tornado width, and total tornado path length
while NDJCount <= 29:
x = df.loc[Date23:Date24]
NDJReports.insert(NDJCount,len(x.index))
y = x.DEATHS_DIRECT.sum()
NDJDeath.insert(NDJCount,y)
z = x.INJURIES_DIRECT.sum()
NDJInjury.insert(NDJCount,z)
c = x.Total_Damages.sum()
NDJCost.insert(NDJCount,c)
NDJReportDays = 1
#nested if statements to calculate report days based on 12Z to 12Z the next day as 1 day
if len(x.index) == 0:
NDJReportDaysList.insert(NDJCount, 0)
else:
for i in range(1, len(x.index)):
if ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] < 1200))):
continue
elif ((x.Z_Day[i] == x.Z_Day[i-1]) and ((x.Z_Time[i] >= 1200) and (x.Z_Time[i-1] >= 1200))):
continue
elif (x.Z_Day[i] == (x.Z_Day[i-1] + pd.DateOffset(days=1))) and ((x.Z_Time[i] < 1200) and (x.Z_Time[i-1] >= 1200)):
continue
else:
NDJReportDays = NDJReportDays + 1
NDJReportDaysList.insert(NDJCount, NDJReportDays)
Date23 = Date23 + pd.DateOffset(years=1)
Date24 = Date24 + pd.DateOffset(years=1)
NDJCount = NDJCount + 1
#Create dataframes for each list
NDJdf1 = pd.DataFrame({'NDJ Reports': NDJReports})
NDJdf2 = pd.DataFrame({'NDJ Report Days': NDJReportDaysList})
NDJdf3 = pd.DataFrame({'NDJ Fatalities': NDJDeath})
NDJdf4 = pd.DataFrame({'NDJ Injuries': NDJInjury})
NDJdf5 = pd.DataFrame({'NDJ Damages': NDJCost})
#concatenate the dataframes together
NDJdftot = pd.concat([
NDJdf1, NDJdf2, NDJdf3, NDJdf4,
NDJdf5], axis=1)
years = []
for i in range(1981,2011):
years.insert(i,i)
NDJdftot = NDJdftot.set_index([years])
In [14]:
DJFdftot.to_csv('DJFFloodingImpacts.csv')
JFMdftot.to_csv('JFMFloodingImpacts.csv')
FMAdftot.to_csv('FMAFloodingImpacts.csv')
MAMdftot.to_csv('MAMFloodingImpacts.csv')
AMJdftot.to_csv('AMJFloodingImpacts.csv')
MJJdftot.to_csv('MJJFloodingImpacts.csv')
JJAdftot.to_csv('JJAFloodingImpacts.csv')
JASdftot.to_csv('JASFloodingImpacts.csv')
ASOdftot.to_csv('ASOFloodingImpacts.csv')
SONdftot.to_csv('SONFloodingImpacts.csv')
ONDdftot.to_csv('ONDFloodingImpacts.csv')
NDJdftot.to_csv('NDJFloodingImpacts.csv')
In [ ]: