VertexFrame timeseries_slice


timeseries_slice(self, date_time_index, start, end)

Returns a frame that is a sub-slice of the given series.

Parameters:

date_time_index : list

DateTimeIndex to conform all series to.

start : datetime

The start date for the slice in the ISO 8601 format, like: yyyy-MM-dd’T’HH:mm:ss.SSSZ

end : datetime

The end date for the slice (inclusive) in the ISO 8601 format, like: yyyy-MM-dd’T’HH:mm:ss.SSSZ.

Returns:

: Frame

Splits a time series frame on the specified start and end date/times.

Examples

For this example, we start with a frame that has already been formatted as a time series. This means that the frame has a string column for key and a vector column that contains a series of the observed values. We must also know the date/time index that corresponds to the time series.

The time series is in a Frame object called ts_frame.

>>> ts_frame.inspect()
[#]  key  series
==============================================
[0]  A    [62.0, 55.0, 60.0, 61.0, 60.0, 59.0]
[1]  B    [60.0, 58.0, 61.0, 62.0, 60.0, 61.0]
[2]  C    [69.0, 68.0, 68.0, 70.0, 71.0, 69.0]

Next, we define the date/time index. In this example, it is one day intervals from 2016-01-01 to 2016-01-06:

>>> datetimeindex = ["2016-01-01T12:00:00.000Z","2016-01-02T12:00:00.000Z","2016-01-03T12:00:00.000Z","2016-01-04T12:00:00.000Z","2016-01-05T12:00:00.000Z","2016-01-06T12:00:00.000Z"]

Get a slice of our time series from 2016-01-02 to 2016-01-04:

Take a look at our sliced time series:

>>> sliced_frame.inspect()
[#]  key  series
============================
[0]  A    [55.0, 60.0, 61.0]
[1]  B    [58.0, 61.0, 62.0]
[2]  C    [68.0, 68.0, 70.0]