Previous topic

scikits.timeseries.TimeSeries.asfreq

Next topic

scikits.timeseries.convert

This Page

scikits.timeseries.TimeSeries.convert

TimeSeries.convert(series, freq, func=None, position='END', *args, **kwargs)

Converts a series from one frequency to another, by manipulating both the data and dates attributes.

If the input series has any missing dates, it will first be filled in with masked values prior to doing the conversion.

Parameters:

series : TimeSeries

Series to convert. Skip this parameter if you are calling this as a method of the TimeSeries object instead of the module function.

freq : freq_spec

Frequency to convert the TimeSeries to. Accepts any valid frequency specification (string or integer)

func : function, optional

When converting a series to a lower frequency, the func parameter to perform a calculation on each period of values to aggregate results. For example, when converting a daily series to a monthly series, use numpy.ma.mean to get a series of monthly averages. If the first or last value from a period, the functions first_unmasked_val and last_unmasked_val should be used instead. If func is not given, the output series group the points of the initial series that share the same new date. Thus, if the initial series has a daily frequency and is 1D, the output series is 2D.

position : {‘END’, ‘START’}, optional

When converting a series to a higher frequency, use this parameter to determine where the points should fall in the new period. For example, when converting a monthly series to daily, using position=’START’ will cause the values to fall on the first day of each month (with all other values being masked).

*args : {extra arguments for func parameter}, optional

Mandatory parameters of the func function.

**kwargs : {extra keyword arguments for func parameter}, optional

Optional keyword parameters of the func function.

Returns:

converted_series :

A new TimeSeries at the given frequency, without any missing nor duplicated dates