From 9ebe41de5fe40903294efa6152ca069c954dc2f0 Mon Sep 17 00:00:00 2001 From: AaronCooke2718 <121969609+AaronCooke2718@users.noreply.github.com> Date: Thu, 23 Nov 2023 12:13:33 -0500 Subject: [PATCH] Update processing.py --- covid19_drdfm/processing.py | 91 +++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/covid19_drdfm/processing.py b/covid19_drdfm/processing.py index bfadd4f..ed81356 100644 --- a/covid19_drdfm/processing.py +++ b/covid19_drdfm/processing.py @@ -1,3 +1,6 @@ +# %% + + """I/O and processing module Converts all input files into single consolidated dataframe that can be used @@ -129,3 +132,91 @@ def add_datetime(df: pd.DataFrame) -> pd.DataFrame: df = df.assign(Month=pd.to_numeric(df.Period.apply(lambda x: x[1:]))).assign(Day=1) df["Time"] = pd.to_datetime({"year": df.Year, "month": df.Month, "day": df.Day}) return df.drop(columns=["Period", "Month", "Year", "Day"]) + +# %% +def fix_names(df: pd.DataFrame) -> pd.DataFrame: + df = df.rename(columns={'Cases1': 'Pandemic_1', 'Cases2': 'Pandemic_2',\ + 'Cases3': 'Pandemic_3', 'Cases4': 'Pandemic_4', \ + 'Cases5': 'Pandemic_5', 'Hosp1': 'Pandemic_6',\ + 'Hosp2': 'Pandemic_7', 'Deaths1': 'Pandemic_8', \ + 'Deaths2': 'Pandemic_9', 'Deaths3': 'Pandemic_10'\ + 'Deaths4': 'Pandemic_11', 'Deaths5': 'Pandemic_12'\ + 'Vax1': 'Pandemic_Response_1', 'Vax2': 'Pandemic_Response_2',\ + 'Vax3': 'Pandemic_Response_3', 'Gather1': 'Pandemic_Response_4', \ + 'Gather2': 'Pandemic_Response_5', 'Gather3': 'Pandemic_Response_6',\ + 'Gather4': 'Pandemic_Response_7', 'SaH': 'Pandemic_Response_8', \ + 'Curfew': 'Pandemic_Response_9', 'Mask1': 'Pandemic_Response_10'\ + 'Mask2': 'Pandemic_Response_11', 'School': 'Pandemic_Response_12'\ + 'Cons1': 'Demand_1', 'Cons2': 'Demand_2',\ + 'Cons3': 'Demand_3', 'Cons4': 'Demand_4',\ + 'Cons5': 'Demand_5', 'Employment1': 'Demand_6',\ + 'Employment2': 'Demand_7', 'GDP': 'Supply_1',\ + 'UI': 'Supply_2', 'PartR': 'Supply_3',\ + 'UR': 'Supply_4', 'RPFI': 'Supply_5',\ + 'FixAss': 'Supply_6', 'Prod': 'Supply_7',\ + 'CPI': 'Monetary_1', 'CPIU': 'Monetary_2',\ + 'PCE': 'Monetary_3', 'PCEC': 'Monetary_4',\ + 'TBill1mo': 'Monetary_5', 'TBill6mo': 'Monetary_6',\ + 'TBill1yr': 'Monetary_7', 'TBill5yr': 'Monetary_8',\ + 'TBill10yr': 'Monetary_9', 'TBill30yr': 'Monetary_10',\ + 'FFR': 'Monetary_11'}) + """ + #write the code that will change the dataframes names + # Look at other pandemic functions + # return modified version of the dataframe + # Have test code to validate""" + +def factordic() + factors = {} + factors[Cases1] = 'Global', 'Pandemic' + factors[Cases2] = 'Global', 'Pandemic' + factors[Cases3] = 'Global', 'Pandemic' + factors[Cases4] = 'Global', 'Pandemic' + factors[Cases5] = 'Global', 'Pandemic' + factors[Hosp1] = 'Global', 'Pandemic' + factors[Hosp2] = 'Global', 'Pandemic' + factors[Deaths1] = 'Global', 'Pandemic' + factors[Deaths2] = 'Global', 'Pandemic' + factors[Deaths3] = 'Global', 'Pandemic' + factors[Deaths4] = 'Global', 'Pandemic' + factors[Deaths5] = 'Global', 'Pandemic' + factors[Vax1] = 'Global', 'Response' + factors[Vax2] = 'Global', 'Response' + factors[Vax3] = 'Global', 'Response' + factors[Gather1] = 'Global', 'Response' + factors[Gather2] = 'Global', 'Response' + factors[Gather3] = 'Global', 'Response' + factors[Gather4] = 'Global', 'Response' + factors[SaH] = 'Global', 'Response' + factors[Curfew] = 'Global', 'Response' + factors[Mask1] = 'Global', 'Response' + factors[Mask2] = 'Global', 'Response' + factors[School] = 'Global', 'Response' + factors[Cons1] = 'Global', 'Consumption' + factors[Cons2] = 'Global', 'Consumption' + factors[Cons3] = 'Global', 'Consumption' + factors[Cons4] = 'Global', 'Consumption' + factors[Cons5] = 'Global', 'Consumption' + factors[Employment1] = 'Global', 'Employment' + factors[Employment2] = 'Global', 'Employment' + factors[UI] = 'Global', 'Employment' + factors[PartR] = 'Global', 'Employment' + factors[UR] = 'Global', 'Employment' + factors[CPI] = 'Global', 'Inflation' + factors[CPIU] = 'Global', 'Inflation' + factors[PCE] = 'Global', 'Inflation' + factors[PCEC] = 'Global', 'Inflation' + factors[RPFI] = 'Global', 'Uncat' + factors[FixAss] = 'Global', 'Uncat' + factors[Prod] = 'Global', 'Uncat' + factors[GDP] = 'Global', 'Uncat' + factors[TBill1mo] = 'Global', 'Uncat' + factors[TBill6mo] = 'Global', 'Uncat' + factors[TBill1yr] = 'Global', 'Uncat' + factors[TBill5yr] = 'Global', 'Uncat' + factors[TBill10tr] = 'Global', 'Uncat' + factors[TBill30yr] = 'Global', 'Uncat' + factors[TBillFFR] = 'Global', 'Uncat' + + +