0

Using the following code, I am trying to extract two dates from an object in mongodb and then calculate the difference in time between the two dates -- if both year are in/past 2016. My current code raises the following error:

DeprecationWarning: generator 'QuerySet._iter_results' raised StopIteration from ipykernel import kernelapp as app

My code: raw_data = Document.objects()

data = []
for i in raw_data[:10]:
    scored = i.date_scored
    scored_date =  pd.to_datetime(scored, format='%Y-%m-%d %H:%M')
    if scored_date == "NoneType":
        print("none")
    elif scored_date.year >= 2016:
        extracted = i.date_extracted
        extracted_date =  pd.to_datetime(extracted, format='%Y-%m-%d 
        %H:%M')
        bank = i.bank.name
        diff = scored_date - extracted_date
        print(diff)
        datum = [str(bank), str(extracted), str(scored), str(diff)]
        data.append(datum)
    else:
        pass

Any help would be appreciated, thank you!

Graham Streich
  • 874
  • 3
  • 15
  • 31

0 Answers0