Skip to content

Commit

Permalink
added area column function and modified mapping main script
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan2Y79 committed Dec 3, 2024
1 parent 6dfc78f commit cfa1969
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/mapping/mapping_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,30 @@ def create_additional_ni_cols(ni_full_responses: pd.DataFrame, config: dict) ->
ni_full_responses["itl"] = config["mappers"]["ni_itl"]

return ni_full_responses


def add_area_columns(df):
"""
Add area columns to the dataframe bassed on ITL121NM column.
Args:
df (pd.DataFrame): The dataframe to add the area columns to.
Returns:
pd.DataFrame: The dataframe with the area columns added.
"""
area_dict = {'South East (England)': 'select',
'East': 'select',
'London': 'select',
'West Midlands (England)': 'other',
'Wales': 'other',
'North East (England)': 'other',
'East Midlands (England)': 'other',
'Yorkshire and The Humber': 'other',
'Scotland': 'other',
'South West (England)': 'other',
'North West (England)': 'other'}

df['area'] = df['ITL121NM'].map(area_dict)

return df
4 changes: 4 additions & 0 deletions src/mapping/mapping_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ def run_mapping(
full_responses, postcode_mapper, itl_mapper, config
)

# add area column if PNP
if config["survey"]["survey_type"] == "PNP":
full_responses = hlp.add_area_columns(full_responses)

# Process the NI full responses if they exist
if not ni_full_responses.empty:
ni_full_responses = hlp.create_additional_ni_cols(ni_full_responses, config)
Expand Down

0 comments on commit cfa1969

Please sign in to comment.