Skip to content

Commit

Permalink
Merge pull request #951 from CodeForPhilly/lebovits/issu919-fix-land-…
Browse files Browse the repository at this point in the history
…bank-props

Lebovits/issu919 fix land bank props
  • Loading branch information
nlebovits authored Oct 11, 2024
2 parents da9184f + 5b9f4aa commit c13fec8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
30 changes: 26 additions & 4 deletions data/src/data_utils/access_process.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
def access_process(dataset):
from typing import Any

def access_process(dataset: Any) -> Any:
"""
Process a dataset to determine the access process for each property based on
city ownership and market value. The result is added as a new column in the dataset.
Args:
dataset (Any): The dataset containing a GeoDataFrame named `gdf` with
columns "city_owner_agency" and "market_value".
Returns:
Any: The updated dataset with an additional "access_process" column.
Side Effects:
Prints the distribution of the "access_process" column.
"""
access_processes = []

for _, row in dataset.gdf.iterrows():
Expand All @@ -9,9 +25,9 @@ def access_process(dataset):
)

# Simplified decision logic
if city_owner_agency == "PLB":
access_process = "Land Bank"
elif city_owner_agency in ["PRA", "PHDC"]:
if city_owner_agency == "Land Bank (PHDC)":
access_process = "Go through Land Bank"
elif city_owner_agency == "PRA":
access_process = "Do Nothing"
else:
if market_value_over_1000:
Expand All @@ -22,4 +38,10 @@ def access_process(dataset):
access_processes.append(access_process)

dataset.gdf["access_process"] = access_processes

# Print the distribution of "access_process"
distribution = dataset.gdf["access_process"].value_counts()
print("Distribution of access process:")
print(distribution)

return dataset
20 changes: 19 additions & 1 deletion data/src/data_utils/city_owned_properties.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
from typing import Any
from classes.featurelayer import FeatureLayer
from constants.services import CITY_OWNED_PROPERTIES_TO_LOAD

def city_owned_properties(primary_featurelayer: FeatureLayer) -> FeatureLayer:
"""
Processes city-owned property data by joining it with the primary feature layer,
renaming columns, and updating access information for properties based on ownership.
All instances where the "city_owner_agency" is "PLB" are changed to "Land Bank (PHDC)".
def city_owned_properties(primary_featurelayer):
Args:
primary_featurelayer (FeatureLayer): The primary feature layer to which city-owned
property data will be joined.
Returns:
FeatureLayer: The updated primary feature layer with processed city ownership
information.
"""
city_owned_properties = FeatureLayer(
name="City Owned Properties",
esri_rest_urls=CITY_OWNED_PROPERTIES_TO_LOAD,
Expand Down Expand Up @@ -60,4 +73,9 @@ def city_owned_properties(primary_featurelayer):
"side_yard_eligible"
].fillna("No")

# Update all instances where city_owner_agency is "PLB" to "Land Bank (PHDC)"
primary_featurelayer.gdf.loc[
primary_featurelayer.gdf["city_owner_agency"] == "PLB", "city_owner_agency"
] = "Land Bank (PHDC)"

return primary_featurelayer
2 changes: 1 addition & 1 deletion data/src/data_utils/conservatorship.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def conservatorship(primary_featurelayer):
sale_date_6_months_ago = False

# Simplified decision logic
if city_owner_agency == "PLB" or (
if city_owner_agency == "Land Bank (PHDC)" or (
not sale_date_6_months_ago and market_value_over_1000
):
conservatorship = "No"
Expand Down

0 comments on commit c13fec8

Please sign in to comment.