Skip to content

Commit

Permalink
Refactoring pnp_pre_processing.py
Browse files Browse the repository at this point in the history
  • Loading branch information
woodac committed Dec 4, 2024
1 parent 04c8416 commit cfcdb04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/site_apportionment/pnp_pre_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@ def pnp_pre_processing(df: pd.DataFrame) -> pd.DataFrame:
# Add a column for imputation marker
df = imputation_marker(df)
# Add a column for a weight
df = pnp_weight(df)

df = pnp_columns(df)
return df

# Add a column for a weight
def pnp_weight(df: pd.DataFrame) -> pd.DataFrame:
def pnp_columns(df: pd.DataFrame) -> pd.DataFrame:

"""Add a class column to the PNP data.
"""Adding columns to run PNP data.
Args:
df (pd.DataFrame): The input DataFrame.
Returns:
pd.DataFrame: The DataFrame with the added weight column.
pd.DataFrame: The DataFrame with the added weight and pg_numeric column.
"""
# Add a class column to the PNP data
df["a_weight"] = 1.0
df["pg_numeric"] = 10

return df
return df
5 changes: 3 additions & 2 deletions src/site_apportionment/site_apportionment_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ def run_site_apportionment(
to apportion for long forms
"""
if config ["survey"]["survey_type"] == "PNP":
pnp_pre_processing(df)

df = pnp_pre_processing(df)


# Create variable for output of QA apportionment file
qa_path = config["apportionment_paths"]["qa_path"]

Expand Down

0 comments on commit cfcdb04

Please sign in to comment.