Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added scripts/hazusConsequence2CollapseProb.py #68

Merged
merged 2 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

df['collapse_pc'].div(100) will also work here


# 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()