diff --git a/data/src/data_utils/llc_owner.py b/data/src/data_utils/llc_owner.py deleted file mode 100644 index 181c5772..00000000 --- a/data/src/data_utils/llc_owner.py +++ /dev/null @@ -1,16 +0,0 @@ -def llc_owner(primary_featurelayer): - llc_owners = [] - - for _, row in primary_featurelayer.gdf.iterrows(): - # Extracting owner1 and owner2 from the row - owner1 = str(row["owner_1"]).lower() - owner2 = str(row["owner_2"]).lower() - - # Checking if " llc" is in either owner1 or owner2 - if " llc" in owner1 or " llc" in owner2: - llc_owners.append("Yes") - else: - llc_owners.append("No") - - primary_featurelayer.gdf["llc_owner"] = llc_owners - return primary_featurelayer diff --git a/data/src/data_utils/owner_type.py b/data/src/data_utils/owner_type.py new file mode 100644 index 00000000..291364df --- /dev/null +++ b/data/src/data_utils/owner_type.py @@ -0,0 +1,37 @@ +import pandas as pd +from classes.featurelayer import FeatureLayer + +def owner_type(primary_featurelayer: FeatureLayer) -> FeatureLayer: + """ + Determines the ownership type for each property in the primary feature layer based on + the 'owner_1', 'owner_2', and 'city_owner_agency' columns. The ownership type is set as: + - "Public" if 'city_owner_agency' is not NA. + - "Business (LLC)" if 'city_owner_agency' is NA and "LLC" is found in 'owner_1' or 'owner_2'. + - "Individual" if 'city_owner_agency' is NA and "LLC" is not found in 'owner_1' or 'owner_2'. + + Args: + primary_featurelayer (FeatureLayer): The feature layer containing property ownership data. + + Returns: + FeatureLayer: The updated feature layer with the 'owner_type' column added. + """ + owner_types = [] + + for _, row in primary_featurelayer.gdf.iterrows(): + # Extract owner1, owner2, and city_owner_agency + owner1 = str(row["owner_1"]).lower() + owner2 = str(row["owner_2"]).lower() + city_owner_agency = row["city_owner_agency"] + + # Determine ownership type based on the conditions + if pd.notna(city_owner_agency): + owner_types.append("Public") + elif " llc" in owner1 or " llc" in owner2: + owner_types.append("Business (LLC)") + else: + owner_types.append("Individual") + + # Add the 'owner_type' column to the GeoDataFrame + primary_featurelayer.gdf["owner_type"] = owner_types + + return primary_featurelayer diff --git a/data/src/script.py b/data/src/script.py index 763de925..c5f3a8aa 100644 --- a/data/src/script.py +++ b/data/src/script.py @@ -16,7 +16,7 @@ from data_utils.gun_crimes import gun_crimes from data_utils.imm_dang_buildings import imm_dang_buildings from data_utils.l_and_i import l_and_i -from data_utils.llc_owner import llc_owner +from data_utils.owner_type import owner_type from data_utils.nbhoods import nbhoods from data_utils.negligent_devs import negligent_devs from data_utils.opa_properties import opa_properties @@ -50,7 +50,7 @@ imm_dang_buildings, tactical_urbanism, conservatorship, - llc_owner, + owner_type, community_gardens, park_priority, ppr_properties, diff --git a/src/components/FilterView.tsx b/src/components/FilterView.tsx index fab565d7..2666f12c 100644 --- a/src/components/FilterView.tsx +++ b/src/components/FilterView.tsx @@ -51,9 +51,9 @@ const filters = [ type: 'buttonGroup', }, { - property: 'llc_owner', + property: 'owner_type', display: 'Owner', - options: ['Yes', 'No'], + options: ['Public', 'Business (LLC)', 'Individual'], type: 'buttonGroup', }, ]; diff --git a/src/components/Filters/DimensionFilter.tsx b/src/components/Filters/DimensionFilter.tsx index fdd1a391..0c7f374a 100644 --- a/src/components/Filters/DimensionFilter.tsx +++ b/src/components/Filters/DimensionFilter.tsx @@ -19,9 +19,10 @@ type OptionDisplayMapping = { }; const optionsDisplayMapping: OptionDisplayMapping = { - llc_owner: { - Yes: 'Business', - No: 'Individual', + owner_type: { + Public: 'Public', + 'Business (LLC)': 'Business (LLC)', + Individual: 'Individual', }, };