tspy.data_structures.multi_time_series.SegmentMultiTimeSeries module¶
-
class
tspy.data_structures.multi_time_series.SegmentMultiTimeSeries.
SegmentMultiTimeSeries
(tsc, j_mts)¶ Bases:
tspy.data_structures.multi_time_series.MultiTimeSeries.MultiTimeSeries
A special form of multi-time-series that consists of observations with a value of type
Segment
- Attributes
keys
Returns
Methods
aggregate
(zero, seq_func, comb_func)aggregate all series in this multi-time-series to produce a single value
aggregate_series
(list_to_val_func)aggregate all time-series in the multi-time-series using a summation function to produce a single time-series
aggregate_series_with_key
(list_to_val_func)aggregate all time-series with key in the multi-time-series using a summation function to produce a single time-series
align
(key[, interp_func])align all time-series on a key
cache
([cache_size])suggest to the multi-time-series to cache values
collect
([inclusive])collect and materialize this multi-time-series
collect_series
(key[, inclusive])get a collection of observations given a key
describe
()retrieve a
NumStats
object per time-series computed from all values in this multi-time-series (double)fillna
(interpolator[, null_value])produce a new multi-time-series which is the result of filling all null values.
filter
(func)produce a new multi-time-series which is the result of filtering by each observation’s value given a filter function.
filter_series
(func)filter each time-series by its time-series object
filter_series_key
(func)filter each time-series by its key
flatten
([key_func])converts this segment-multi-time-series into a multi-time-series where each time-series will be the result of a single segment
forecast
(num_predictions, fm[, …])forecast the next num_predictions using a forecasting model for each time-series
full_align
(multi_time_series[, …])align two multi-time-series based on a temporal full join strategy and optionally interpolate missing values
full_join
(multi_time_series[, join_func, …])join two multi-time-series based on a temporal full join strategy and optionally interpolate missing values
get_time_series
(key)get a time-series given a key
get_values
(start, end[, inclusive])get all values between a range in this multi-time-series
inner_align
(multi_time_series)align two multi-time-series based on a temporal inner join strategy
inner_join
(multi_time_series[, join_func])join two multi-time-series based on a temporal inner join strategy
left_align
(multi_time_series[, interp_func])align two multi-time-series based on a temporal left join strategy and optionally interpolate missing values
left_join
(multi_time_series[, join_func, …])join two multi-time-series based on a temporal left join strategy and optionally interpolate missing values
left_outer_align
(multi_time_series[, …])align two multi-time-series based on a temporal left outer join strategy and optionally interpolate missing values
left_outer_join
(multi_time_series[, …])join two multi-time-series based on a temporal left outer join strategy and optionally interpolate missing values
map
(func)produce a new multi-time-series where each observation’s value in this multi-time-series is mapped to a new observation value
map_series
(func)map each
ObservationCollection
to a new collection of observationsmap_series_key
(func)map each time-series key to a new key
map_series_with_key
(func)map each
ObservationCollection
to a new collection of observations giving access to each time-series keypair_wise_transform
(binary_transform)produce a new multi-time-series which is the product of performing a pair-wise transform against all combination of keys
print
([start, end, inclusive])print this multi-time-series
reduce
(func)reduce each time-series in this multi-time-series to a single value
reduce_range
(func, start, end[, inclusive])reduce each time-series in this multi-time-series to a single value given a range
resample
(period, interp_func)produce a new multi-time-series by resampling each time-series to a given periodicity
right_align
(multi_time_series[, interp_func])align two multi-time-series based on a temporal right join strategy and optionally interpolate missing values
right_join
(multi_time_series[, join_func, …])join two multi-time-series based on a temporal right join strategy and optionally interpolate missing values
right_outer_align
(multi_time_series[, …])align two time-series based on a temporal right outer join strategy and optionally interpolate missing values
right_outer_join
(multi_time_series[, …])join two multi-time-series based on a temporal right outer join strategy and optionally interpolate missing values
segment
(window[, step, enforce_bounds])produce a new segment-multi-time-series from a performing a sliding-based segmentation over each time-series
segment_by
(func)produce a new segment-multi-time-series from a performing a group-by operation on each observation’s value for each time-series
segment_by_anchor
(func, left_delta, right_delta)produce a new segment-multi-time-series from performing an anchor-based segmentation over each time-series.
segment_by_changepoint
([change_point])produce a new segment-multi-time-series from performing a chang-point based segmentation.
segment_by_time
(window, step)produce a new segment-multi-time-series from a performing a time-based segmentation over each time-series
time_series
(key)get a time-series given a key
to_df
([format, inclusive])convert this multi-time-series to a pandas dataframe.
to_df_instants
([inclusive])convert this multi-time-series to an observations pandas dataframe.
to_df_observations
([inclusive])convert this multi-time-series to an observations pandas dataframe.
to_segments
(segment_transform)produce a new segment-multi-time-series from a segmentation transform
transform
(*args)produce a new multi-time-series which is the result of performing a transforming over each time-series.
trs
(key)get a time-series time-reference-system given a key
uncache
()remove the multi-time-series caching mechanism
with_trs
([granularity, time_tick])create a new multi-time-series with its timestamps mapped based on a granularity and start_time.
write
([start, end, inclusive])create a multi-time-series-writer given a range
-
flatten
(key_func=None)¶ converts this segment-multi-time-series into a multi-time-series where each time-series will be the result of a single segment
- Parameters
- key_funcfunc, optional
operation where given a segment, produce a unique key (default is create key based on start of segment)
- Returns
MultiTimeSeries
a new multi-time-series
Notes
this is not a lazy operation and will materialize the time-series
Examples
create a simple multi-time-series
>>> import tspy >>> mts_orig = tspy.multi_time_series.dict({'a': tspy.data_structures.list([1,2,3]), 'b': tspy.data_structures.list([4,5,6])}) >>> mts_orig a time series ------------------------------ TimeStamp: 0 Value: 1 TimeStamp: 1 Value: 2 TimeStamp: 2 Value: 3 b time series ------------------------------ TimeStamp: 0 Value: 4 TimeStamp: 1 Value: 5 TimeStamp: 2 Value: 6
segment the multi-time-series using a simple sliding window
>>> mts_sliding = mts_orig.segment(2) >>> mts_sliding a time series ------------------------------ TimeStamp: 0 Value: original bounds: (0,1) actual bounds: (0,1) observations: [(0,1),(1,2)] TimeStamp: 1 Value: original bounds: (1,2) actual bounds: (1,2) observations: [(1,2),(2,3)] b time series ------------------------------ TimeStamp: 0 Value: original bounds: (0,1) actual bounds: (0,1) observations: [(0,4),(1,5)] TimeStamp: 1 Value: original bounds: (1,2) actual bounds: (1,2) observations: [(1,5),(2,6)]
flatten the segments into a single multi-time-series
>>> mts = mts_sliding.flatten() >>> mts (a, 0) time series ------------------------------ TimeStamp: 0 Value: 1 TimeStamp: 1 Value: 2 (b, 0) time series ------------------------------ TimeStamp: 0 Value: 4 TimeStamp: 1 Value: 5 (a, 1) time series ------------------------------ TimeStamp: 1 Value: 2 TimeStamp: 2 Value: 3 (b, 1) time series ------------------------------ TimeStamp: 1 Value: 5 TimeStamp: 2 Value: 6