[SciPy-User] Error calling mov_max() on scikits.timeseries object

David Mrva david.mrva@isamfunds....
Wed Jun 30 07:02:50 CDT 2010

Hello All,

As a new user to scikits.timeseries, I started with a simple piece of code: read a one column timeseries data from a CSV file and find moving maxima.

How should I correctly use the mov_max() function with a timeseries object?

When I call the mov_max() function, I keep getting an exception:

>>> import numpy as np
>>> import scikits.timeseries as ts
>>> import scikits.timeseries.lib.moving_funcs as mf
>>> b=ts.tsfromtxt("test4.csv", delimiter=',', names='price', datecols=(0), dtype='float')
>>> b
timeseries([(5277.0,) (5214.0,) (5180.0,) (5092.5,)],
   dtype = [('price', '<f8')],
   dates = [737791 738156 738521 738886],
   freq  = U)

>>> c=mf.mov_max(b, 2)
Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\scikits\timeseries\lib\moving_funcs.py", line 228, in mov_max
    return _moving_func(data, MA_mov_max, kwargs)
  File "C:\Python26\lib\site-packages\scikits\timeseries\lib\moving_funcs.py", line 121, in _moving_func
    data = ma.fix_invalid(data)
  File "C:\Python26\lib\site-packages\numpy\ma\core.py", line 516, in fix_invalid
    invalid = np.logical_not(np.isfinite(a._data))
AttributeError: logical_not

Where the contents of the test4.csv file is:
24/06/2010 09:10,5092.5
23/06/2010 09:10,5180
22/06/2010 09:10,5214
21/06/2010 09:10,5277

Calling mov_max() on a list of numbers works fine.

Many thanks for any tips,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100630/35ed12e2/attachment.html 

More information about the SciPy-User mailing list