Skip to content

Commit

Permalink
Renaming df's and implementing in apply_estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jday7879 committed Dec 17, 2024
1 parent 8afee7a commit 856becf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions mbs_results/estimation/apply_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions mbs_results/estimation/create_population_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 856becf

Please sign in to comment.