On Jun 10, 2010, at 7:16 PM, Bevan Jenkins wrote:
> Hello,
> 
> I have posted previously about dates prior to 1900 but this seems to be a 
> seperate issue.  The error message is definitley different.
> I can not seem to convert a timseseries from one frequency ('D') to another 
> ('H') when i use dates prior to 1970 as shown below.  This works fine when I 
> use a date after 1970.  Is this something that can be easily fixed or work 
> around that I can use? Thanks


Argh, major bug indeed... For frequencies below days, the reference is 1AD. 
Above that, the reference is the unix epoch (1970/01/01). When you try to use 
dates before that epoch with an hourly frequency, you get negative integers 
that are not properly dealt with... I gonna work on that.
In the meantime, you can use the following (extremely ugly) trick:

>>> s_d = ts.time_series(np.arange(5) + 1,
                         start_date=ts.Date('D', "1969/01/01"))
>>> # This fails: 
>>> # s.convert('H')
>>> # Create s hortcut to dates (to save some __getattr__ time)
>>> d = s_d.dates
>>> # Calculate the offset from the unix epoch
>>> offset = ts.Date('D', year=1970, month=1, day=1) - d[0]
>>> # Create a new temporary series
>>> s_h = s_d
>>> # Add the offset to the dates, so that you're after the epoch
>>> s_h.dates += offset
>>> # Convert to HOURLY
>>> s_h = s_h.convert('H')
>>> # Subtract the offset (don't forget to convert to 'H')
>>> s_h.dates -= offset * 24

Your predicament is far from over now, because you won't be able to print the 
dates... But that's another bug.
I'll keep you posted when we have some better solutions.


_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to