From 856becfc346f22caba36c69af987e6e3f0a20db1 Mon Sep 17 00:00:00 2001 From: Jordan Day Date: Tue, 17 Dec 2024 11:12:31 +0000 Subject: [PATCH] Renaming df's and implementing in apply_estimation --- mbs_results/estimation/apply_estimation.py | 7 +++++++ mbs_results/estimation/create_population_counts.py | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/mbs_results/estimation/apply_estimation.py b/mbs_results/estimation/apply_estimation.py index bcb0d97..aadf4c5 100644 --- a/mbs_results/estimation/apply_estimation.py +++ b/mbs_results/estimation/apply_estimation.py @@ -6,6 +6,9 @@ calculate_calibration_factor, calculate_design_weight, ) +from mbs_results.estimation.create_population_counts import ( + create_population_count_output, +) from mbs_results.estimation.pre_processing_estimation import get_estimation_data from mbs_results.staging.data_cleaning import is_census @@ -94,6 +97,10 @@ def apply_estimation( estimation_df = pd.concat(estimation_df_list, ignore_index=True) + create_population_count_output( + estimation_df, period, calibration_group, save_output=True, **config + ) + # validate_estimation(estimation_df, **config) return estimation_df diff --git a/mbs_results/estimation/create_population_counts.py b/mbs_results/estimation/create_population_counts.py index 585cfb9..b2309a3 100644 --- a/mbs_results/estimation/create_population_counts.py +++ b/mbs_results/estimation/create_population_counts.py @@ -71,14 +71,14 @@ def create_population_count_output( Returns none if save_output is True """ - df_1 = calculate_turnover_sum_count( + df_population = calculate_turnover_sum_count( df, period, strata, colname="population", **config ) - df_2 = calculate_turnover_sum_count( + df_sampled = calculate_turnover_sum_count( df.loc[df["sampled"]], period, strata, colname="sample", **config ) - combined = pd.merge(df_1, df_2, on=[period, strata]) + combined = pd.merge(df_population, df_sampled, on=[period, strata]) if save_output: combined.to_csv(output_path + "population_counts.csv", index=False)