Closed DrAndiLowe closed 6 years ago
Also, see here for info on this bug: https://bugs.python.org/issue29097
Not too sure how datetime values are treated. I tried a workaround of converting all dates to Unix timestamps, negative values included, but the results were terrible; converting back to dates gets me a much much smaller range of dates than in the input data. So that's not a solution. Somehow I need dates before 1970 to be treated properly. Any ideas?
For a workaround solution, if the datetime values are dates, you can first convert them to integers. After generating synthetic dataset, convert integers back to dates.
>>> from dateutil.parser import parse
>>> date0 = parse('01/01/1970')
>>> date1 = parse('19/04/1979')
>>> date2 = parse('19/04/1969')
>>> date3 = parse('06/08/2018')
>>> (date1-date0).days
3395
>>> (date2-date0).days
-257
>>> (date3-date0).days
17690
With regards to my previous comment about the distributions of datetime attributes being synthesised poorly: implementing #11 resolves this issue after converting to integers as you suggested in your reply. That is, converting to integers wasn't the source of the behaviour I saw. Replacing timestamp()
with a simple count of seconds from a user-defined epoch start will probably be sufficient to close this issue.
In DateTimeAttribute.py, line 65:
timestamp()
results in a crash for dates earlier than 1970:This is apparently a known Python bug: see this Stack Overflow post.
The same problem seems to occur with
timestamp()
; I tried this from a Python command prompt:If you're not seeing this behaviour, the SO post hints that Windows systems are affected, but not Linux.
Is there way to replace the translation from dates to timestamps, and vice versa, with code that works for dates earlier than 1970-01-01?