Im developing a python script where I have list of release dates and a df which I would want to create a new column and call a function to check how many release dates before the product is completed.
The function calls two parameters which is dates as well. But I’m getting error which I don’t know why.
The error message is:
KeyError: "None of [DatetimeIndex(['2099-01-01 00:00:00', '2099-01-01 00:00:00',n '2099-01-01 00:00:00', '2024-03-22 11:55:00',n '2024-02-09 22:46:00', '2024-04-18 10:57:00',n '2099-01-01 00:00:00', '2099-01-01 00:00:00',n '2023-10-26 14:03:00', '2023-12-14 17:42:00',n ...n '2099-01-01 00:00:00', '2024-04-08 05:50:00',n '2024-04-23 07:58:00', '2024-04-05 08:05:00',n '2099-01-01 00:00:00', '2099-01-01 00:00:00',n '2024-04-04 14:16:00', '2099-01-01 00:00:00',n '2024-04-02 12:35:00', '2099-01-01 00:00:00'],n dtype='datetime64[ns]', length=7319, freq=None)] are in the [columns]"
The code:
df["efixcount"] = df.apply(efixcheckoverall(pd.Timestamp(df[df['Date Completed For Customers']]),pd.Timestamp(df[df['Date Set (Current)']])) , axis=1)
The function:
def efixcheckoverall(datecompleted,dateset):
ctr = 0
for x in efix_list:
if dateset<= x :
if datecompleted >= x:
ctr+=1
#print(x)
#print(ctr)
return ctr
Have the error fixed and maybe correct my logic on getting the iteration of how many release dates count starting from date set up to date completed