({{, (RefLink[TimeSeriesWindow, paclet:ref/TimeSeriesWindow])[tseries,{(Subscript[t, min]),(Subscript[t, max])}] 
gives the elements of the time series tseries that fall between (Subscript[t, min]) and (Subscript[t, max]).}, {, (RefLink[TimeSeriesWindow, paclet:ref/TimeSeriesWindow])[tseries,windowspec]
gives the elements of the time series tseries that satisfy the window specification windowspec.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[TimeSeriesWindow, paclet:ref/TimeSeriesWindow]) is used to select a subset of a time series that falls in a given window.

The time series tseries can be a list of numeric values {(Subscript[x, 1]),(Subscript[x, 2]),…}, a list of time-value pairs {{(Subscript[t, 1]),(Subscript[x, 1])},{(Subscript[t, 2]),(Subscript[x, 2])},…}, a (RefLink[TimeSeries, paclet:ref/TimeSeries]), (RefLink[EventSeries, paclet:ref/EventSeries]), or (RefLink[TemporalData, paclet:ref/TemporalData]).

The window times (Subscript[t, min]) and (Subscript[t, max]) can be given as (RefLink[Automatic, paclet:ref/Automatic]), numbers, or dates. When (Subscript[t, min]) or (Subscript[t, max]) are given as (RefLink[Automatic, paclet:ref/Automatic]), the first and last times in tseries are used, respectively.

The window specification windowspec can be given as:

Possible dayspec types are: "Weekday", "Weekend", (RefLink[Monday, paclet:ref/Monday]) through (RefLink[Sunday, paclet:ref/Sunday]), "BeginningOfMonth", "EndOfMonth", "BusinessDay" and "Holiday".

(RefLink[TimeSeriesWindow, paclet:ref/TimeSeriesWindow]) takes the following options:

By default, the window times (Subscript[t, min]) and (Subscript[t, max]) are included only if they are also members of the times {(Subscript[t, 1]),(Subscript[t, 2]),…} in tseries.

If (Subscript[t, min]) and (Subscript[t, max]) are outside the range of the {(Subscript[t, 1]),(Subscript[t, 2]),…}, then the (Subscript[t, 1]) and (Subscript[t, n]) are used, respectively.

OpenersPrimaryExamplesSection(Spacer1)Examples  (15)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Extract a portion of a time series:

ts=TimeSeries[FinancialData["GOOGL",{"1 Jan 2012","1 Jan 2014"}]];

DateListPlot[ts]

Take the elements between May 4 and August 4 of 2012:

win=TimeSeriesWindow[ts,{{2012,5,4},{2012,8,4}}];

DateListPlot[win]

Extract elements from June 2012:

TimeSeriesWindow[ts, DateObject[{2012, 6}, "Month"]]

Extract elements that fall at the end of each month:

end=TimeSeriesWindow[ts,"EndOfMonth"]

DateListPlot[end,PlotMarkers->Automatic]

OpenersExampleSection1(Spacer1)Scope  (8)

OpenersExampleSubsection0(Spacer1)Basic Uses  (3)

Select a subset of a time series:

data={{1,(Subscript[x, 1])},{2,(Subscript[x, 2])},{3,(Subscript[x, 3])},{4,(Subscript[x, 4])},{5,(Subscript[x, 5])}};

TimeSeriesWindow[data,{2,4}]

Select Fridays from a time series with dates:

ts=TimeSeries[];

fridays=TimeSeriesWindow[ts,Friday]

DateListPlot[{ts,fridays},Joined->{True,False}, Filling->2->0,FillingStyle->Directive[Black,Thick]]

Visualize different subsets of a time series:

data=TimeSeries[RandomFunction[ARIMAProcess[{.1},1,{.2},1],{1000}]];

ListLinePlot[data]

Split the data into three parts:

win1=TimeSeriesWindow[data,{Automatic,300}];
win2=TimeSeriesWindow[data,{300,700}];
win3=TimeSeriesWindow[data,{700,Automatic}];

ListLinePlot[{win1,win2,win3},PlotLegends->{"win1","win2","win3"}]

OpenersExampleSubsection1(Spacer1)Data Types  (5)

Extract three elements from a vector:

v={a,b,c,d,e};

TimeSeriesWindow[v,{2,4}]

Select the values for a specific interval of times in a list of time-value pairs:

v={{1,a},{3,b},{7,c},{14,d},{15,e}};

TimeSeriesWindow[v,{2,8}]

Extract 50 values from a (RefLink[TimeSeries, paclet:ref/TimeSeries]):

ts=TimeSeries[];

win=TimeSeriesWindow[ts,{10,59}]

Overlay the window over the original data:

ListLinePlot[{ts,win}]

Extract 30 values from an (RefLink[EventSeries, paclet:ref/EventSeries]):

es=EventSeries[];

win=TimeSeriesWindow[es,{10,39}]

Overlay the window over the original data:

ListPlot[{es,win},Filling->Axis]

Restrict the paths of (RefLink[TemporalData, paclet:ref/TemporalData]) to a smaller interval:

td=RandomFunction[WienerProcess[],{0,20,0.01},5]

win=TimeSeriesWindow[td,{3,15}]

ListLinePlot[#,PlotRange->{{0,20},{-10,10}}]&/@{td,win}

OpenersExampleSection2(Spacer1)Options  (4)

OpenersExampleSubsection2(Spacer1)IncludeWindowTimes  (1)

By default, the window times are included only if they are among the time stamps:

ts={{1,1},{2,2},{3,3},{4,4}};

TimeSeriesWindow[ts,{2,3}]

If the window times are not time stamps, they are excluded:

TimeSeriesWindow[ts,{1.5,3.5}]

Specify that window times should be included:

TimeSeriesWindow[ts,{1.5,3.5},IncludeWindowTimes->True]

Include only the right window time:

TimeSeriesWindow[ts,{1.5,3.5},IncludeWindowTimes->{False,True}]

OpenersExampleSubsection3(Spacer1)ResamplingMethod  (1)

Specify what values to assign to window times that are not among the time stamps:

s={(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4])};
t={2,4,6,8};

td=TimeSeries[s,{t}];
td//Normal

By default, interpolation of order 0 is used:

win1=TimeSeriesWindow[td,{4,6.4},IncludeWindowTimes->True];

win1//Normal

Use interpolation of order 1:

win2=TimeSeriesWindow[td,{4,6.4},IncludeWindowTimes->True,ResamplingMethod->{"Interpolation",InterpolationOrder->1}];

win2//Normal

Use a fixed constant:

win3=TimeSeriesWindow[td,{4,6.4},ResamplingMethod->{"Constant",c},IncludeWindowTimes->True];

win3//Normal

OpenersExampleSubsection4(Spacer1)CalendarType  (1)

Use the Jewish calendar:

data={{{5777,1,10},1},{{5777,1,11},2},{{5777,1,12},3},{{5777,1,13},4},{{5777,1,14},5},{{5777,1,15},6}};

TimeSeriesWindow[data,"Weekend",CalendarType->"Jewish"]

OpenersExampleSubsection5(Spacer1)HolidayCalendar  (1)

Extract business days:

ts=TimeSeries[Range[20],{{2017,4,10}}];

res=TimeSeriesWindow[ts,"BusinessDay",HolidayCalendar->"Germany"]

DateListPlot[{ts,res},Joined->False,Filling->2->0]

OpenersExampleSection3(Spacer1)Applications  (2)

This time series contains the number of steps taken daily by a person during a period of five months:

stepdata=TimeSeries[];

Display the daily step counts for each of the months:

monthlyTS=Table[TimeSeriesWindow[stepdata,DateObject[{2013,k}]],{k,4,8}];

months={"April","May","June","July","August"};DateListPlot[monthlyTS,PlotLegends->months]

Display the total number of steps for each month:

monthlyTotals=Total/@monthlyTS;

PieChart[monthlyTotals,ChartLabels->Placed[{monthlyTotals,months},{"RadialCenter","RadialCallout"}]]

Visualize the temperature in Champaign during the summer of 2014:

td=TimeSeries[];

Extract the temperatures for summer months:

summer=TimeSeriesWindow[td,{(DateObject["Day: ""Sun 1 Jun 2014", DateObject[{2014,6,1},"Day","Gregorian",-6.`]]),(DateObject["Day: ""Mon 1 Sep 2014", DateObject[{2014,9,1},"Day","Gregorian",-6.`]])}]

Find some basic descriptive statistics:

{Min[#],Mean[#],Max[#]}&@summer

DateListPlot[{td,summer},FrameLabel->Automatic]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[MovingMap, paclet:ref/MovingMap])  ▪  (RefLink[TimeSeriesAggregate, paclet:ref/TimeSeriesAggregate])  ▪  (RefLink[TimeSeriesResample, paclet:ref/TimeSeriesResample])  ▪  (RefLink[TimeSeriesThread, paclet:ref/TimeSeriesThread])  ▪  (RefLink[RegularlySampledQ, paclet:ref/RegularlySampledQ])  ▪  (RefLink[MinimumTimeIncrement, paclet:ref/MinimumTimeIncrement])  ▪  (RefLink[TimeSeriesShift, paclet:ref/TimeSeriesShift])  ▪  (RefLink[TimeSeriesRescale, paclet:ref/TimeSeriesRescale])  ▪  (RefLink[TimeSeriesMap, paclet:ref/TimeSeriesMap])  ▪  (RefLink[TimeSeriesMapThread, paclet:ref/TimeSeriesMapThread])  ▪  (RefLink[TimeSeriesInsert, paclet:ref/TimeSeriesInsert])  ▪  (RefLink[TimeSeriesModelFit, paclet:ref/TimeSeriesModelFit])  ▪  (RefLink[TemporalData, paclet:ref/TemporalData])  ▪  (RefLink[TimeSeries, paclet:ref/TimeSeries])  ▪  (RefLink[EventSeries, paclet:ref/EventSeries])  ▪  (RefLink[ResamplingMethod, paclet:ref/ResamplingMethod])  ▪  (RefLink[IncludeWindowTimes, paclet:ref/IncludeWindowTimes])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Time Series Processing, paclet:guide/TimeSeries])}})}})