0

I have a bunch of field data, where some have a well known acquisition day, while for some the acquisition is just known with an unvertainty margin, say +/- 1.5 months as an example.

Is there something such as an "uncertain datetime object" that could handle these uncertainties?

I was thinking to insert just "99" and "99" for day and month as a zeroth order approach and then for example create an Enum object that labels the date as uncertain. But first of all inserting nines doesn't work, because datetime takes good care that you insert valid month and day when instantiating a datetime object. Is there a cleverer aprroach to this? Is there maybe an already existing package than can deal with uncertain dates?

user3017048
  • 2,711
  • 3
  • 22
  • 32

1 Answers1

0

An entry like +/- 1.5 is a difference from some measured time. One way you can codify this is with a timedelta object, which represents the difference in two datetime objects.

Here is how you would represent an interval of minus five minutes:

import datetime

i = datetime.timedelta(minutes=-5)

Now, to calculate a time you just add that to an actual date time value.

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284