[SciPy-User] ValueError with ts.convert of scikits.timeseries

Marco Tuckner marcotuckner@public-files...
Wed Mar 3 16:47:11 CST 2010


Hello,
I encountered an error working with a recarray read from a ASCII file
with ts.tsfromtxt [1].

The steps were conducted:

1) read in with ts.tsfromtxt ==> recarray with data with minutely frequency
2) missing dates were filed with ts.fill_missing_dates ==> complete series
3) convert into hourly frequency with ts.convert
4) an error occurs, see below.

What could be the cause for this?

My recarray have the following dtypes:

 dtype = [('f2', '<i4'), ('f3', '<f8'), ('f4', '<f8'), ('f5', '<i4'),
('f6', '<i4'), ('f7', '<f8'), ('f8', '<f8'), ('f9', '<f8'), ('f10',
'<f8'), ('f11', '<f8'), ('f12', '<f8')],

Another question related to this:
How do I convert the recarrays returned by ts.tsfromtxt into a ndarray?

I would like to transform the recarray in a form similar to what is
returned data is loaded with np.loadtxt (and then pushed in a timeseries)?

I would appreciate any help.

Thanks in advance,
Marco

##### Traceback #####

[C:scripts/eval]|103> run dataeval.py
------------------------------------------------------------------------
---
ValueError                                Traceback (most recent call
last)

C:\scripts\eval\dataeval.py in <module>()
     42 myseries_filled_min = ts.fill_missing_dates(series)
     43
---> 44 myseries_hourly_mean =
ts.convert(myseries_filled_min,'H',func=np.mean)

C:\Python26\lib\site-packages\scikits\timeseries\tseries.pyc in
convert(series, freq, func, position, *args, **kwargs)
   2003
   2004     if series.ndim == 1:
-> 2005         obj = _convert1d(series, freq, func, position, *args,
**kwargs)
   2006     elif series.ndim == 2:
   2007         base = _convert1d(series[:,0], freq, func, position,
*args, **kwargs)

C:\Python26\lib\site-packages\scikits\timeseries\tseries.pyc in
_convert1d(series, freq, func, position, *args, **kwargs)
   1913
   1914     cdictresult = cseries.TS_convert(data_, from_freq, to_freq,
position,
-> 1915                                      int(start_date), mask_)
   1916     start_date = Date(freq=to_freq,
value=cdictresult['startindex'])
   1917     data_ = masked_array(cdictresult['values'],
mask=cdictresult['mask'])

ValueError: data type must provide an itemsize
WARNING: Failure executing file: <dataeval.py>


#####

[1]: http://pytseries.sourceforge.net/core.timeseries.io.html



More information about the SciPy-User mailing list