Skip to content

Commit 117a5ea

Browse files
authored
Changes (#2)
* Delete ncdes directory * Delete public_meta_data directory * Delete LICENSE * Delete README.md * Delete environment.yml * Add files via upload * Add files via upload
1 parent 89cea17 commit 117a5ea

5 files changed

Lines changed: 30 additions & 202036 deletions

File tree

ncdes/create_publication.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,15 @@ def main() -> None:
7777
root_directory = root_directory
7878
)
7979

80-
print("Saving output")
80+
print("Joining ruleset ID to copy of output data for ruleset-specific outputs")
81+
NCDes_with_geogs_and_rulesets = processing_steps.merge_mapped_data_with_ruleset_id(NCDes_with_geogs, root_directory)
82+
83+
print("Saving main output")
8184
outputs.save_NCDes_with_geogs_to_csv(NCDes_with_geogs, root_directory)
8285

86+
print("Saving outputs split by ruleset")
87+
outputs.save_NCDes_by_ruleset_to_csvs(NCDes_with_geogs_and_rulesets, root_directory)
88+
8389
print("Archiving input")
8490
outputs.archive_input_as_csv(ncdes_raw, root_directory)
8591

@@ -91,3 +97,4 @@ def main() -> None:
9197

9298
if __name__ == "__main__":
9399
main()
100+

ncdes/output/outputs.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ def save_NCDes_with_geogs_to_csv(NCDes_with_geogs, root_directory):
1313
)
1414

1515

16+
def save_NCDes_by_ruleset_to_csvs(ncdes_with_geogs_and_rulesets, root_directory):
17+
dates_table = get_date_for_name(ncdes_with_geogs_and_rulesets)
18+
file_name = get_file_name(dates_table)
19+
file_folder = get_file_folder(dates_table)
20+
for RULESET_ID in ncdes_with_geogs_and_rulesets['Ruleset ID'].unique():
21+
ncdes_data_ruleset = ncdes_with_geogs_and_rulesets.loc[ncdes_with_geogs_and_rulesets['Ruleset ID'] == RULESET_ID].drop(columns = "Ruleset ID")
22+
ncdes_data_ruleset.to_csv(
23+
f"{root_directory}Output\\" + file_folder + r"\\" + file_name +"_" + RULESET_ID + ".csv",
24+
index=False,
25+
)
26+
1627
def get_date_for_name(NCDes_with_geogs):
1728
"""
1829
Input:
@@ -65,7 +76,7 @@ def get_file_folder(dates_table):
6576

6677
def archive_input_as_csv(ncdes_raw, root_directory):
6778
today = (datetime.today()).strftime("%Y_%m_%d")
68-
ncdes_raw.to_csv(f"{root_directory}Input\\Archive\\NCDes_" + today + ".csv")
79+
ncdes_raw.to_csv(f"{root_directory}Input\\Archive\\NCDes_" + today + ".csv", index=False)
6980

7081

7182
def remove_files_from_input_folder(path):

ncdes/processing/processing_steps.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,4 +388,13 @@ def get_indexes_to_suppress(
388388

389389
index_to_suppress.extend(list_subset_to_suppress)
390390

391-
return index_to_suppress
391+
return index_to_suppress
392+
393+
def merge_mapped_data_with_ruleset_id(ncdes_with_geogs, root_directory):
394+
395+
# Load in measure dictionary
396+
indicator_dictionary = data_load.load_indicator_and_measure_data_dictionaries(root_directory)[0]
397+
# Join ruleset ID onto data
398+
ncdes_with_geogs_and_rulesets = pd.merge(ncdes_with_geogs, indicator_dictionary, left_on = "IND_CODE", right_on = "Indicator ID", how = "left").drop(columns = ["Indicator Description","Payment or Management Information (MI)","Indicator ID"])
399+
400+
return ncdes_with_geogs_and_rulesets

0 commit comments

Comments
 (0)