Skip to content

Commit

Permalink
Added scripts/hazusConsequence2CollapseProb.py (#68)
Browse files Browse the repository at this point in the history
* Added scripts/hazusConsequence2CollapseProb.py

* Added typology column  scripts/hazusConsequence2CollapseProb.py

Co-authored-by: Damon <[email protected]>
  • Loading branch information
DamonU2 and DamonU2 authored Jun 24, 2021
1 parent a607cea commit de45323
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ python-dateutil==2.8.1
pytz==2020.1
six==1.14.0
urllib3==1.26.5
openpyxl==3.0.7
24 changes: 24 additions & 0 deletions scripts/hazusConsequence2CollapseProb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pandas as pd
import openpyxl


def main():
df = pd.read_excel('Hazus_Consequence_Parameters.xlsx',
engine='openpyxl', # Necessary for .xlsx
sheet_name='Collapse Rates',
skiprows=2, header=None, # Drop the first 2 rows,
names=['eqbldgtype', 'collapse_pc']) # Add column names

# Convert percentages to decimal
df['collapse_pc'] /= 100

# Add typology column and copy over eqbldgtype values
df.loc[:, 'typology'] = df['eqbldgtype']

# Convert to .csv and add quotes around all entries
df.to_csv('collapse_probability.csv', index=False,
quoting=1)


if __name__ == '__main__':
main()

0 comments on commit de45323

Please sign in to comment.