Reputation: 33998
I need to add two columns:
df['paidInDays'] = df['sdDatePaidCancelled'].sub(df['sdBillDate'], axis=0) / np.timedelta64(1,'D')
df['toBePaidInDays'] = df['sdDueDate'].sub(df['sdBillDate'], axis=0) / np.timedelta64(1,'D')
However some rows have sdDatePaidCancelled NULL and I cant neither convert it to datetime neither make the calculation.
Any tips to get through this?
Upvotes: 1
Views: 125
Reputation: 862671
It seems you need convert values to datetimes, then NULL
are converted to NaT
and you can subtract values:
cols = ['sdDatePaidCancelled','sdBillDate','sdDueDate']
df[cols] = df[cols].apply(pd.to_datetime)
#if possible some non datetimeslike values
#df[cols] = df[cols].apply(pd.to_datetime, errors='coerce')
Upvotes: 1