I'm trying to write a function that returns some dates in python.
def set_deadline(row):
if row["date1"] is not None:
return row["date1"]+ relativedelta(days=+90)
else:
return None
since some of the records have the date1 field missing (NaT), the error " bad month number nan; must be 1-12" shows up why I try to use this function on my dataframe. How can I change the function so that the deadline would be Nan or None if the date1 field is missing?
I also tried just to define the deadline field by doing the following:
df['Deadline']= df['date1']+ relativedelta(days=+90)
but I got the error, "incompatible type [object] for a datetime/timedelta operation"
Aucun commentaire:
Enregistrer un commentaire