PutTimeSeries function

The PutTimeSeries function puts every element of the first time series into the second time series.

Syntax

PutTimeSeries(ts1   TimeSeries, 
             ts2   TimeSeries,
             flags integer default 0) 
returns TimeSeries;
ts1
The time series to be inserted.
ts2
The time series into which the first time series is to be inserted.
flags
Valid values for the flags argument are described in The flags argument values. The default is 0.

Description

If both time series contain data at the same timepoint, the rule of PutElem is followed (see PutElem function), unless the TS_PUTELEM_NO_DUPS value of the flags parameter is set.

Both time series must have the same calendar. Also, the origin of the time series that is specified by the first argument must be later than or equal to the origin of the time series that is specified by the second argument.

This function can be used to convert a regular time series to an irregular one.
Important: Converting an irregular time series to regular often requires aggregation information, which can be provided by the AggregateBy function.

Elements are added to the second time series by calling ts_put_elem() (if the TS_PUTELEM_NO_DUPS value of the flags parameter is not set).

The API equivalent of this function is ts_put_ts().

Returns

A version of the second time series into which the first time series was inserted.

Example

The following example converts a regular time series to an irregular one. The daily_stocks table holds regular time series data, and the activity_stocks table holds irregular time series data. Additionally, the elements in the daily_stocks time series are converted from stock_bar to stock_trade:
update activity_stocks
    set activity_data = PutTimeSeries(activity_data, 'calendar(daycal),
irregular'::TimeSeries(stock_trade))
    where stock_id = 600;