Skip to content

Commit

Permalink
Create function to convert impute flags into single column with strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Jday7879 committed May 16, 2024
1 parent 122610b commit f1372f0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/imputation_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,23 @@ def create_impute_flags(df, target, reference, strata, auxiliary):
)

return df


def generate_imputation_flag_string(df):
imputation_flag_conditions = [
df["r_flag"],
~df["r_flag"] & df["fir_flag"],
~df["r_flag"] & ~df["fir_flag"] & df["bir_flag"],
~df["r_flag"] & ~df["fir_flag"] & ~df["bir_flag"] & df["fic_flag"],
~df["r_flag"]
& ~df["fir_flag"]
& ~df["bir_flag"]
& ~df["fic_flag"]
& df["c_flag"],
]
flags = ["r", "fir", "bir", "fic", "c"]
df["imputation_flag"] = np.select(
imputation_flag_conditions, flags, default="error"
)

return df

0 comments on commit f1372f0

Please sign in to comment.