Skip to content

Commit

Permalink
Issue #132
Browse files Browse the repository at this point in the history
Write all the crane choices as rows.
  • Loading branch information
akey7 committed Apr 7, 2020
1 parent 9f02c58 commit a238952
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions post_processing_scripts/extract_crane_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

# The extended_landbosse_details dataframe includes all the details along side
# all the project list inputs
print("Reading extended details")
df = pd.read_csv("extended_landbosse_details.csv")

# Extract the crane choice data
print("Selecting crane data")
crane_choice_df = df.query("`Variable name` == 'crane_choice: Crew name - Boom system - Operation'")[[
"Project ID with serial",
"Variable name",
Expand All @@ -19,14 +21,12 @@
"Total project construction time (months)"
]]

# The "Project ID with serial" is the key on the outer dictionary and the
# the crane operations are the keys on the inner dictionary. The values on
# the inner dictionary are the crane choices for each operation.
projects: Dict[str, Dict[str, str]] = {}
aligned_crane_choices = []

print("Selecting unique projects...")
unique_project_id_with_serial = crane_choice_df['Project ID with serial'].unique()


print("Aligning crane types")
for project_id_with_serial in unique_project_id_with_serial:
crane_rows_df = crane_choice_df.query("`Project ID with serial` == @project_id_with_serial")
top_row = crane_rows_df[crane_rows_df["Non-numeric value"].str.contains("Top")]
Expand All @@ -41,7 +41,7 @@
else:
base = "No base crane"

projects[project_id_with_serial] = {
aligned_crane_choice = {
"Project ID with serial": project_id_with_serial,
"Number of turbines": top_row["Number of turbines"].values[0],
"Breakpoint between base and topping (percent)": top_row["Breakpoint between base and topping (percent)"].values[0],
Expand All @@ -54,4 +54,8 @@
"Top": top
}

print(projects[project_id_with_serial])
aligned_crane_choices.append(aligned_crane_choice)

print("Writing crane choices...")
aligned_crane_choice_df = pd.DataFrame(aligned_crane_choices)
aligned_crane_choice_df.to_csv("crane_choices.csv")

0 comments on commit a238952

Please sign in to comment.