-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added scripts/hazusConsequence2CollapseProb.py (#68)
* Added scripts/hazusConsequence2CollapseProb.py * Added typology column scripts/hazusConsequence2CollapseProb.py Co-authored-by: Damon <[email protected]>
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ python-dateutil==2.8.1 | |
pytz==2020.1 | ||
six==1.14.0 | ||
urllib3==1.26.5 | ||
openpyxl==3.0.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |