0

I am trying to get the difference in days between two dates pulled from a SQL database. One is the start date, the other is a completed date. The completed date can and is, in this case, be a NaT value. Essentially I'd like to iterate through each row, and take the difference, if the completed date is NaT I'd like to skip it or assign a NaN value, in a completely new delta column. the code below is giving me this error: 'member_descriptor' object is not callable

for n in df.FINAL_DATE:
  df.DELTA = [0]
  if n is None:
    df.DELTA = None
    break
  else:
    df.DELTA = datetime.timedelta.days(df['FINAL_DATE'], df['START_DATE'])
mitch
  • 379
  • 1
  • 3
  • 14

1 Answers1

0

So, you first have to check if any of the dates are NaT. If not, you can calculate by:

df.DELTA = (df['FINAL_DATE'] -  df['START_DATE']).days
  • absolutely, the only thing is I am trying to set this up so there can be rows without a FINAL_DATE. I intend to monitor data within a database, so I want the program to iterate through the rows and check to see if the FINAL_DATE is "NaT", if it is not I want to do the calculation you shared, otherwise I want it to insert a "NaN" value so as to not mess with an average. – mitch Feb 06 '18 at 16:28