[SciPy-Dev] Problem with manipulating dates in the time series object

Pierre GM pgmdevlist at gmail.com
Wed Sep 22 08:18:41 EDT 2010


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






More information about the SciPy-Dev mailing list