You can also operate on many time-series at the same time by using the MultiTimeSeries construct. A MultiTimeSeries is essentially a dictionary of time series, where each time series has its own unique key. The time
series are not aligned in time.
The MultiTimeSeries construct provides similar methods for transforming and ingesting as the single time series construct:
ts2 time series
------------------------------
TimeStamp: 0 Value: 5.0
TimeStamp: 1 Value: 2.0
TimeStamp: 2 Value: 4.0
TimeStamp: 3 Value: 5.0
ts1 time series
------------------------------
TimeStamp: 0 Value: 1.0
TimeStamp: 1 Value: 2.0
TimeStamp: 2 Value: 3.0
Copy to clipboardCopied to clipboard
Interpreting time
Copy link to section
By default, a time series uses a long data type to denote when a given observation was created, which is referred to as a time tick. A time reference system is used for time series with timestamps that are human interpretable. See
Using time reference system.
The following example shows how to create a simple time series where each index denotes a day after the start time of 1990-01-01:
Similar to the transformers package, you can reduce a time series by using methods provided by the reducers package. You can import the reducers package as follows:
from tspy.builders.functions import reducers
Copy to clipboardCopied to clipboard
After you have imported the package, use the reduce method to get the average over a time-series for example:
avg = ts.reduce(reducers.average())
avg
Copy to clipboardCopied to clipboard
This outputs:
5.0
Copy to clipboardCopied to clipboard
Reducers have a special property that enables them to be used alongside segmentation transformations (hourly sum, avg in the window prior to an error occurring, and others). Because the output of a segmentation + reducer is a
time series, the transform method is used.
For example, to segment into windows of size 3 and get the average across each window, use: