Problem with manipulating dates in the time series object
Hi there, I really like the time series object from scipy but I have a problem with manipulating dates. Here is a copy from my ipython session: ----------------------------------------------------------------------------- In [748]: myts=ts.time_series(data=n.arange(20).reshape(2,10).T, dates=n.arange(10)+720000, freq='D') In [749]: myts Out[749]: timeseries( [[ 0 10] [ 1 11] [ 2 12] [ 3 13] [ 4 14] [ 5 15] [ 6 16] [ 7 17] [ 8 18] [ 9 19]], dates = [17-Apr-1972 ... 26-Apr-1972], freq = D) In [750]: myts.dates[myts.weekday==1]+=1 In [751]: myts.dates Out[751]: DateArray([17-Apr-1972, 19-Apr-1972, 19-Apr-1972, 20-Apr-1972, 21-Apr-1972, 22-Apr-1972, 23-Apr-1972, 24-Apr-1972, 26-Apr-1972, 26-Apr-1972], freq='D') In [752]: myts.has_duplicated_dates() Out[752]: False ----------------------------------------------------------------------------- In words: I can change the dates by hand (in line 750), but the object is not aware of it, i.e. it still thinks that it does not contain any duplicates but the dates were however affected by the manipulation in line 750, cf. line 751. Is there a work-around? all the best. Cheers, Georges
On Sep 22, 2010, at 2:06 PM, gharras wrote:
Hi there,
I really like the time series object from scipy but I have a problem with manipulating dates. Here is a copy from my ipython session:
----------------------------------------------------------------------------- In [748]: myts=ts.time_series(data=n.arange(20).reshape(2,10).T, dates=n.arange(10)+720000, freq='D')
In [749]: myts Out[749]: timeseries( [[ 0 10] [ 1 11] [ 2 12] [ 3 13] [ 4 14] [ 5 15] [ 6 16] [ 7 17] [ 8 18] [ 9 19]], dates = [17-Apr-1972 ... 26-Apr-1972], freq = D)
In [750]: myts.dates[myts.weekday==1]+=1
Shouldn't it be
myts.dates[myts.dates.weekday==1] += 1 myts.dates DateArray([17-Apr-1972, 19-Apr-1972, 19-Apr-1972, 20-Apr-1972, 21-Apr-1972, 22-Apr-1972, 23-Apr-1972, 24-Apr-1972, 26-Apr-1972, 26-Apr-1972], freq='D')
Now, there's still a pb with has_duplicated_dates which is not properly updated. The reason is that we store the status in a cache to avoid having to recalculate it. In most cases, it works, but here, the cache should be deleted... Use myts.dates._reset_cachedinfo() to reset the cache to its default as a workaround. Please fill a ticket as well... Thx
participants (2)
-
gharras -
Pierre GM