Skip to content

Commit

Permalink
added back osmotherly and key references functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan2Y79 committed Jan 10, 2025
1 parent e12f7e2 commit 6db8e9d
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/mapping/pnp_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,44 @@ def add_area_column(df):
df["area"] = df["region"].map(area_dict)

return df


def identify_key_business(df, config):
"""Function to identify the key business using reference column & key
busineses lookup table.
Args:
df (pd.DataFrame): The dataframe to identify the key business columns.
Return:
df (pd.DataFrame): The dataframe with the identified key business columns.
"""
# get key businesses
path = config["mapping_paths"]["key_references"]
key_businesses_df = pd.read_csv(path)
key_businesses_list = list(key_businesses_df["keys"])

df["pnp_key"] = df["reference"].apply(
lambda x: "key0" if x in key_businesses_list else "key1"
)
return df


def identify_osmotherly_businesses(df, config):
"""Function to identify the osmotherly businesses using reference
column & osmotherly busineses lookup table.
Args:
df (pd.DataFrame): The dataframe to identify the osmotherly business
columns.
Return:
df (pd.DataFrame): The dataframe with the identified osmotherly business
columns.
"""
# get osmotherly businesses
path = config["mapping_paths"]["osmotherly_references"]
osmotherly_businesses_df = pd.read_csv(path)
osmotherly_businesses_list = list(osmotherly_businesses_df["ruref"])

df["osmotherly"] = df["reference"].apply(
lambda x: "osTrue" if x in osmotherly_businesses_list else "osFalse"
)

return df

0 comments on commit 6db8e9d

Please sign in to comment.