Skip to content

Commit 3c21734

Browse files
committed
Merge remote-tracking branch 'origin' into SAIL_316_snapshot_date
2 parents 28ffb6a + 1251805 commit 3c21734

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

helpers/regression_estimation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212

1313
sys.path.append("D:/programming_projects/research-and-development")
1414
#%%
15-
from src.utils.local_file_mods import read_local_csv as read_csv
16-
from src.utils.local_file_mods import write_local_csv as write_csv
15+
from src.utils.local_file_mods import rd_read_csv as read_csv
16+
from src.utils.local_file_mods import rd_write_csv as write_csv
1717

1818
#%% Configuration settings
1919

2020
# Input folder and file names
21-
in_fol = "D:/data/res_dev/regression\input/"
22-
in_file_old = "full_estimation_qa_2024-02-02_v106.csv"
23-
in_file_new = "full_estimation_qa_2024-02-02_v107_TEST.csv"
21+
in_fol = "R:/BERD Results System Development 2023/DAP_emulation/2023_surveys/BERD/08_estimation/estimation_qa/"
22+
in_file_old = "2023_full_estimation_qa_26-01-12_v1744.csv"
23+
in_file_new = "2023_full_estimation_qa_26-01-12_v1745.csv"
2424

2525
# Output folder and file
26-
out_fol = "D:/data/res_dev/regression/output/"
26+
out_fol = "D:/data/res_dev/regression/"
2727
out_file = "merged.csv"
2828

2929
# Columns to select

src/estimation/apply_weights.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,17 @@ def apply_weights(
3030
employment_cols = get_all_wanted_columns(config, "employment")
3131
all_numeric_cols = get_all_wanted_columns(config, "estimation")
3232

33-
# if the dataframe is for QA output, create new columns with the weights applied.
3433
if for_qa:
3534
for col in all_numeric_cols:
36-
df[f"{col}_estimated"] = round(df[col] * df["a_weight"], round_val)
35+
df[f"{col}_estimated"] = df[col] * df["a_weight"]
3736
for col in employment_cols:
38-
df[f"{col}_estimated"] = round(df[f"{col}_estimated"] * df["g_weight"], 0)
39-
40-
# otherwise, apply the weights directly to the existing columns
37+
df[f"{col}_estimated"] = df[f"{col}_estimated"] * df["g_weight"]
4138
else:
4239
for col in all_numeric_cols:
43-
df[col] = round(df[col] * df["a_weight"], round_val)
40+
df[col] = df[col] * df["a_weight"]
4441
for col in employment_cols:
45-
df[col] = round(df[col] * df["g_weight"], 0)
42+
df[col] = df[col] * df["g_weight"]
4643

47-
df = calc_totals(df, config, "employment", 0)
44+
df = calc_totals(df, config, "employment", 0)
4845

4946
return df

src/utils/breakdown_validation.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,11 @@ def calc_totals(
187187
for key, columns in equals_checks.items():
188188
if len(columns) == 1:
189189
continue
190-
df[columns[-1]] = round(df[columns[:-1]].sum(axis=1), round_value)
190+
summed = df[columns[:-1]].sum(axis=1)
191+
if round_value > 0:
192+
df[columns[-1]] = round(summed, round_value)
193+
else:
194+
df[columns[-1]] = summed
191195
return df
192196

193197

0 commit comments

Comments
 (0)