From c344c77fe867b6fd96739ad26e858ad44734bc69 Mon Sep 17 00:00:00 2001 From: Hilmar Magnusson Date: Thu, 5 Dec 2024 15:50:29 +0100 Subject: [PATCH] dump: things Signed-off-by: Hilmar Magnusson --- opt.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/opt.py b/opt.py index 6ab2532..d3693d3 100644 --- a/opt.py +++ b/opt.py @@ -27,6 +27,19 @@ class Scheduler: print("Patient data not found") self.create_lists() + self.extend_data() + + def extend_data(self): + + # Date to integer all dates + # tasks date + newcol = [self.date2int(date) for date in self.df_tasks['date'].tolist()] + self.df_tasks.insert(7, "dateint", newcol) + + # block date + newcol2 = [self.date2int(date) for date in self.df_blocks['day'].tolist()] + self.df_blocks.insert(3, "dateint", newcol2) + return def create_lists(self): self.s = self.df_tasks['priority'].tolist() @@ -42,11 +55,14 @@ class Scheduler: return def convert_dates(self): - self.week_day = [self.date2int(date) for date in self.dates] - self.block_week_day = [self.date2int(date) for date in self.block_dates] + self.week_day = [self.date2week_day(date) for date in self.dates] + self.block_week_day = [self.date2week_day(date) for date in self.block_dates] - def date2int(self, date): - d0 = pd.to_datetime("25/11/2024", dayfirst=True) + def date2int(self, date, dzero="25/11/2024"): + return self.date2week_day(date)[0]*7 + self.date2week_day(date)[1] + + def date2week_day(self, date, dzero="25/11/2024"): + d0 = pd.to_datetime(dzero, dayfirst=True) delta = (pd.to_datetime(date, dayfirst=True) - d0).days day = delta%7 week = int((delta - day)/7) @@ -115,7 +131,7 @@ for i in range(n): print(tasks_blocks) -print(sc.dates) -print(sc.week_day) -print(sc.block_dates) -print(sc.block_week_day) +print(sc.df_tasks) +print(sc.df_patients) +print(sc.df_blocks) +print(type(sc.df_blocks))