ba188 commited on
Commit
72cb401
1 Parent(s): 9c51910

Delete data_pre-processing.py

Browse files
Files changed (1) hide show
  1. data_pre-processing.py +0 -55
data_pre-processing.py DELETED
@@ -1,55 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created on Mon Mar 4 09:26:03 2024
4
-
5
- @author: Bethany
6
- """
7
-
8
- import pandas as pd
9
-
10
- # import data
11
- totals_data = pd.read_csv("https://files.digital.nhs.uk/22/D11E7E/HES_M9_2324_OPEN_DATA.csv")
12
- age_groups_data = pd.read_csv("https://files.digital.nhs.uk/D3/2CB1B4/HES_M9_2324_OPEN_DATA_AGE_GROUPS.csv")
13
- specialties_data = pd.read_csv("https://files.digital.nhs.uk/F2/461394/HES_M9_2324_OPEN_DATA_TREATMENT_SPECIALTY.csv")
14
-
15
- # change column names on totals_data to match other files
16
- totals_data = totals_data.rename(columns = {"APC_Finished_Consultant":"FCE",
17
- "APC_FCEs_with_a_procedure":"FCEs_With_Procedure",
18
- "APC_Ordinary_Episodes":"Ordinary_Admission_Episodes",
19
- "APC_Day_Case_Episodes":"FCE_DAY_CASES",
20
- "APC_Day_Case_Episodes_with_proc":"FCE_DAY_WITH_PROCEDURE",
21
- "APC_Finished_Admission_Episodes":"FAE",
22
- "APC_Emergency":"EMERGENCY",
23
- "Outpatient_Total_Appointments":"Total_Appointments",
24
- "Outpatient_Attended_Appointments":"Attended_Appointments",
25
- "Outpatient_DNA_Appointment":"DNA_Appointments",
26
- "Outpatient_Attendance_Type_1":"First_Attendance",
27
- "Outpatient_Attendance_Type_2":"Follow_Up_Attendance"}
28
- )
29
-
30
- # initialise empty dictionary
31
- HES_data= {"months":[]}
32
- # loop through previous dicts for all months
33
- for month in totals_data["CALENDAR_MONTH_END_DATE"][:69]:
34
- month_dict = {}
35
- month_dict.update({"month":list(totals_data["CALENDAR_MONTH_END_DATE"])[list(totals_data["CALENDAR_MONTH_END_DATE"]).index(month)]})
36
- month_dict.update({c:{} for c in age_groups_data.columns[5:]})
37
-
38
- for key in list(month_dict.keys())[1:]:
39
- # fill in sub-dictionaries with values from the three different csvs
40
- month_dict[key].update({"total":totals_data[key][0],
41
- "age_bands":[],
42
- "specialties":[]})
43
-
44
- for age in list(age_groups_data["Age_Band"].unique()):
45
- age_bands = {"age_band":age,
46
- key:age_groups_data[key][list(age_groups_data["Age_Band"].unique()).index(age)]}
47
- month_dict[key]["age_bands"].append(age_bands)
48
-
49
- for spec in list(specialties_data["TRETSPEF"].unique()):
50
- specialties = {"treatment_specialty_code":spec,
51
- "treatement_specialty_description":list(specialties_data["TRETSPEF_DESCRIPTION"].unique())[list(specialties_data["TRETSPEF"].unique()).index(spec)],
52
- key:specialties_data[key][list(specialties_data["TRETSPEF"].unique()).index(spec)]}
53
- month_dict[key]["specialties"].append(specialties)
54
-
55
- HES_data["months"].append(month_dict)