dump: things

Signed-off-by: Hilmar Magnusson <hilmar.magnusson@bisdn.de>
This commit is contained in:
Hilmar Magnusson 2024-12-05 15:50:29 +01:00
parent 5d99a1fbea
commit c344c77fe8
1 changed files with 24 additions and 8 deletions

32
opt.py
View File

@ -27,6 +27,19 @@ class Scheduler:
print("Patient data not found") print("Patient data not found")
self.create_lists() 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): def create_lists(self):
self.s = self.df_tasks['priority'].tolist() self.s = self.df_tasks['priority'].tolist()
@ -42,11 +55,14 @@ class Scheduler:
return return
def convert_dates(self): def convert_dates(self):
self.week_day = [self.date2int(date) for date in self.dates] self.week_day = [self.date2week_day(date) for date in self.dates]
self.block_week_day = [self.date2int(date) for date in self.block_dates] self.block_week_day = [self.date2week_day(date) for date in self.block_dates]
def date2int(self, date): def date2int(self, date, dzero="25/11/2024"):
d0 = pd.to_datetime("25/11/2024", dayfirst=True) 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 delta = (pd.to_datetime(date, dayfirst=True) - d0).days
day = delta%7 day = delta%7
week = int((delta - day)/7) week = int((delta - day)/7)
@ -115,7 +131,7 @@ for i in range(n):
print(tasks_blocks) print(tasks_blocks)
print(sc.dates) print(sc.df_tasks)
print(sc.week_day) print(sc.df_patients)
print(sc.block_dates) print(sc.df_blocks)
print(sc.block_week_day) print(type(sc.df_blocks))