[SciPy-User] scikits.timeseries.tsfromtxt & guess

Pierre GM pgmdevlist@gmail....
Mon Jan 4 14:35:57 CST 2010

On Jan 4, 2010, at 3:25 PM, Tim Michelsen wrote:

>> I'd first create the time series from the input, then try to guess the frequency from the DateArray
> So you'd recommend to create the timeseries using the userdefined
> frequency ('U')
> def mydateconverter(year, month, day, hour, freq='U'):
>    freq = ts.extras.guess_freq(year, month, day, hour)
>    ts_date =  ts.Date(freq, year=int(year), month=int(month), day=int(day))
>    return ts_date
> and then use guess_freq to assign the correct one?

Basically, yes. Note that guess_freq is only for convenience, it might not be fool-proof...

> I want to have the dateconverters in a flexible style only variyng by
> input format and clumns used. They should be working regardless of the
> frequency (be the data set hourly or minutely).

Well, you could define a converter class that takes freq as input and test in the __call__ for the value of the freq. You could have a variable nb of inputs in __call__ and test for the nb of parameters (year, month, day...). It won't be as efficient as defining a specific converter for your data, though...

More information about the SciPy-User mailing list