mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
adding outcomes writing
This commit is contained in:
parent
45b372b9ae
commit
b6ef41b21b
2 changed files with 30 additions and 18 deletions
|
|
@ -354,6 +354,7 @@ class AssetList:
|
|||
self.contact_detail_fields = None
|
||||
self.outcomes = None
|
||||
self.outcomes_no_match = None
|
||||
self.outcomes_for_output = None
|
||||
self.master_surveyed = None
|
||||
|
||||
# We detect the presence of the non-intrusive columns
|
||||
|
|
@ -1414,8 +1415,6 @@ class AssetList:
|
|||
# Floor type check
|
||||
self.standardised_asset_list["solar_epc_floor_is_solid_no_recommendation"] &
|
||||
# SAP Below threshold
|
||||
self.standardised_asset_list[self.ATTRIBUTE_SAP_THRESHOLD_AND_BELOW] &
|
||||
# SAP above threshold
|
||||
self.standardised_asset_list[self.ATTRIBUTE_SAP_THRESHOLD_AND_BELOW]
|
||||
)
|
||||
# With heating upgrade, above threshold
|
||||
|
|
@ -1431,8 +1430,6 @@ class AssetList:
|
|||
self.standardised_asset_list["solar_epc_roof_insulated"] &
|
||||
# Floor type check
|
||||
self.standardised_asset_list["solar_epc_floor_is_solid_no_recommendation"] &
|
||||
# SAP Below threshold
|
||||
self.standardised_asset_list[self.ATTRIBUTE_SAP_THRESHOLD_AND_BELOW] &
|
||||
# SAP above threshold
|
||||
~self.standardised_asset_list[self.ATTRIBUTE_SAP_THRESHOLD_AND_BELOW]
|
||||
)
|
||||
|
|
@ -1677,14 +1674,6 @@ class AssetList:
|
|||
# ~self.standardised_asset_list["solar_eligible_other_floor_needs_loft"]
|
||||
)
|
||||
|
||||
blocks_of_flats = self.standardised_asset_list[
|
||||
self.standardised_asset_list[self.STANDARD_PROPERTY_TYPE] == "block of flats"
|
||||
]
|
||||
|
||||
non_blocks_of_flats = self.standardised_asset_list[
|
||||
self.standardised_asset_list[self.STANDARD_PROPERTY_TYPE] != "block of flats"
|
||||
]
|
||||
|
||||
# Finally, we note why each property has been flagged
|
||||
self.standardised_asset_list["cavity_reason"] = None
|
||||
self.standardised_asset_list["cavity_reason"] = np.where(
|
||||
|
|
@ -1794,12 +1783,35 @@ class AssetList:
|
|||
self.standardised_asset_list["cavity_reason"]
|
||||
)
|
||||
|
||||
blocks_of_flats = self.standardised_asset_list[
|
||||
self.standardised_asset_list[self.STANDARD_PROPERTY_TYPE] == "block of flats"
|
||||
]
|
||||
|
||||
non_blocks_of_flats = self.standardised_asset_list[
|
||||
self.standardised_asset_list[self.STANDARD_PROPERTY_TYPE] != "block of flats"
|
||||
]
|
||||
|
||||
# Produce some aggregate figures
|
||||
self.work_type_figures = {
|
||||
**self.standardised_asset_list["cavity_reason"].value_counts().to_dict(),
|
||||
**non_blocks_of_flats["cavity_reason"].value_counts().to_dict(),
|
||||
**{
|
||||
k + " (Block of flats)": v for k, v in
|
||||
blocks_of_flats["solar_reason"].value_counts().to_dict().items()
|
||||
},
|
||||
**self.standardised_asset_list["solar_reason"].value_counts().to_dict()
|
||||
}
|
||||
|
||||
# We prepare outcomes for output
|
||||
if self.outcomes:
|
||||
logger.info("Preparing outcomes for output")
|
||||
identified_work = self.standardised_asset_list[
|
||||
~pd.isnull(self.standardised_asset_list["cavity_reason"]) |
|
||||
~pd.isnull(self.standardised_asset_list["solar_reason"])
|
||||
][self.DOMNA_PROPERTY_ID].values
|
||||
self.outcomes_for_output = self.outcomes[
|
||||
self.outcomes[self.DOMNA_PROPERTY_ID].isin(identified_work)
|
||||
]
|
||||
|
||||
def flat_analysis(self):
|
||||
|
||||
# We need to deduce the building name - we strip out the house number
|
||||
|
|
@ -2225,8 +2237,6 @@ class AssetList:
|
|||
self.outcomes[["row_id", "Outcome", "Notes", date_col]], how="left", on="row_id"
|
||||
)
|
||||
|
||||
df = lookup[lookup["domna_property_id"] == "44beckettavenuegainsboroughdn211en-1d4811cbb046"]
|
||||
|
||||
visit_counts = (
|
||||
lookup.groupby(self.DOMNA_PROPERTY_ID)["row_id"]
|
||||
.count()
|
||||
|
|
@ -2245,15 +2255,15 @@ class AssetList:
|
|||
|
||||
# We merge this data onto outcomes
|
||||
self.outcomes["matched_to_asset_list"] = self.outcomes["row_id"].isin(lookup["row_id"].values)
|
||||
self.outcomes = self.outcomes.merge(
|
||||
lookup, how="left", on="row_id"
|
||||
)
|
||||
self.outcomes = self.outcomes.merge(lookup[["row_id", "domna_property_id"]], how="left", on="row_id")
|
||||
|
||||
# We merge out pivoted outcomes onto the asset list
|
||||
self.standardised_asset_list = self.standardised_asset_list.merge(
|
||||
pivot_df, how="left", left_on=self.DOMNA_PROPERTY_ID, right_on="domna_property_id"
|
||||
)
|
||||
|
||||
self.outcomes = self.outcomes.sort_values("domna_property_id", ascending=False)
|
||||
|
||||
def flag_survey_master(
|
||||
self,
|
||||
master_filepaths,
|
||||
|
|
|
|||
|
|
@ -684,6 +684,8 @@ def app():
|
|||
asset_list.standardised_asset_list.to_excel(writer, sheet_name="Standardised Asset List", index=False)
|
||||
asset_list.flat_data.to_excel(writer, sheet_name="Flat Data", index=False)
|
||||
# If we have outcomes, we add a tab with the outcomes
|
||||
if asset_list.outcomes_for_output is not None:
|
||||
asset_list.outcomes_for_output.to_excel(writer, sheet_name="Outcomes", index=False)
|
||||
|
||||
# Store the Hubspot export as a csv
|
||||
hubspot_data.to_csv(os.path.join(data_folder, "Hubspot Export.csv"), index=False)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue