---
title: "TimeSeriesWindow"
language: "en"
type: "Symbol"
summary: "TimeSeriesWindow[tseries, {tmin, tmax}] gives the elements of the time series tseries that fall between tmin and tmax. TimeSeriesWindow[tseries, windowspec] gives the elements of the time series tseries that satisfy the window specification windowspec."
keywords: 
- time series part
- temporal data part
- time series chunk
- split time series
canonical_url: "https://reference.wolfram.com/language/ref/TimeSeriesWindow.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Time Series Processing"
    link: "https://reference.wolfram.com/language/guide/TimeSeries.en.md"
related_functions: 
  - 
    title: "MovingMap"
    link: "https://reference.wolfram.com/language/ref/MovingMap.en.md"
  - 
    title: "TimeSeriesAggregate"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesAggregate.en.md"
  - 
    title: "TimeSeriesResample"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesResample.en.md"
  - 
    title: "TimeSeriesThread"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesThread.en.md"
  - 
    title: "RegularlySampledQ"
    link: "https://reference.wolfram.com/language/ref/RegularlySampledQ.en.md"
  - 
    title: "MinimumTimeIncrement"
    link: "https://reference.wolfram.com/language/ref/MinimumTimeIncrement.en.md"
  - 
    title: "TimeSeriesShift"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesShift.en.md"
  - 
    title: "TimeSeriesRescale"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesRescale.en.md"
  - 
    title: "TimeSeriesMap"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesMap.en.md"
  - 
    title: "TimeSeriesMapThread"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesMapThread.en.md"
  - 
    title: "TimeSeriesInsert"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesInsert.en.md"
  - 
    title: "TimeSeriesModelFit"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesModelFit.en.md"
  - 
    title: "TemporalData"
    link: "https://reference.wolfram.com/language/ref/TemporalData.en.md"
  - 
    title: "TimeSeries"
    link: "https://reference.wolfram.com/language/ref/TimeSeries.en.md"
  - 
    title: "EventSeries"
    link: "https://reference.wolfram.com/language/ref/EventSeries.en.md"
  - 
    title: "ResamplingMethod"
    link: "https://reference.wolfram.com/language/ref/ResamplingMethod.en.md"
  - 
    title: "IncludeWindowTimes"
    link: "https://reference.wolfram.com/language/ref/IncludeWindowTimes.en.md"
---
# TimeSeriesWindow

TimeSeriesWindow[tseries, {tmin, tmax}] gives the elements of the time series tseries that fall between tmin and tmax.

TimeSeriesWindow[tseries, windowspec] gives the elements of the time series tseries that satisfy the window specification windowspec.

## Details and Options

* ``TimeSeriesWindow`` is used to select a subset of a time series that falls in a given window.

[image]

* The time series ``tseries`` can be a list of numeric values ``{x1, x2, …}``, a list of time-value pairs ``{{t1, x1}, {t2, x2}, …}``, a ``TimeSeries``, ``EventSeries``, or ``TemporalData``.

* The window times ``tmin`` and ``tmax`` can be given as ``Automatic``, numbers, or dates. When ``tmin`` or ``tmax`` are given as ``Automatic``, the first and last times in ``tseries`` are used, respectively.

* The window specification ``windowspec`` can be given as:

|                     |                              |
| ------------------- | ---------------------------- |
|  {tmin, tmax}       | time or date limits          |
| DateObject[_, gran] | a single granular DateObject |
| dayspec             | use day specification        |

* Possible ``dayspec`` types are: ``"Weekday"``, ``"Weekend"``, ``Monday`` through ``Sunday``, ``"BeginningOfMonth"``, ``"EndOfMonth"``, ``"BusinessDay"`` and ``"Holiday"``.

* ``TimeSeriesWindow`` takes the following options:

|                     |                             |                                                                             |
| ------------------- | --------------------------- | --------------------------------------------------------------------------- |
| ResamplingMethod    | Automatic                   | the method to use for resampling paths                                      |
| IncludeWindowTimes  | False                       | whether to create values at tmin and tmax if not members of the time stamps |
| CalendarType        | "Gregorian"                 | the calendar system to interpret the dates                                  |
| HolidayCalendar     | {"UnitedStates", "Default"} | the holiday calendar schedule for business days                             |

* By default, the window times ``tmin`` and ``tmax`` are included only if they are also members of the times ``{t1, t2, …}`` in ``tseries``.

* If ``tmin`` and ``tmax`` are outside the range of the ``{t1, t2, …}``, then the ``t1`` and ``tn`` are used, respectively.

---

## Examples (15)

### Basic Examples (1)

Extract a portion of a time series:

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

In[2]:= DateListPlot[ts]

Out[2]= [image]
```

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

```wl
In[3]:= win = TimeSeriesWindow[ts, {{2012, 5, 4}, {2012, 8, 4}}];

In[4]:= DateListPlot[win]

Out[4]= [image]
```

Extract elements from June 2012:

```wl
In[5]:= TimeSeriesWindow[ts, DateObject[{2012, 6}, "Month"]]

Out[5]=
TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{21}, 
     {{285.7770080566406, 289.5799865722656, 285.47601318359375, 290.58099365234375, 
       289.3800048828125, 290.4809875488281, 284.5249938964844, 282.8240051269531 ...     3549744000, 3549830400, 3549916800}]}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {DateFunction -> Automatic, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, 
   TemporalRegularity -> True, ValueDimensions -> 1}}, True, 12.1]
```

Extract elements that fall at the end of each month:

```wl
In[6]:= end = TimeSeriesWindow[ts, "EndOfMonth"]

Out[6]=
TemporalData[TimeSeries, {{{Quantity[290.33599853515625, "USDollars"], 
    Quantity[309.42498779296875, "USDollars"], Quantity[302.7179870605469, "USDollars"], 
    Quantity[290.71099853515625, "USDollars"], Quantity[316.8070068359375, "USDollars" ...    3589488000, 3592166400, 3597436800}}}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {DateFunction -> Automatic, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, 
   TemporalRegularity -> True, ValueDimensions -> 1}}, True, 314.1]

In[7]:= DateListPlot[end, PlotMarkers -> Automatic]

Out[7]= [image]
```

### Scope (8)

#### Basic Uses (3)

Select a subset of a time series:

```wl
In[1]:= data = {{1, Subscript[x, 1]}, {2, Subscript[x, 2]}, {3, Subscript[x, 3]}, {4, Subscript[x, 4]}, {5, Subscript[x, 5]}};

In[2]:= TimeSeriesWindow[data, {2, 4}]

Out[2]= {{2, Subscript[x, 2]}, {3, Subscript[x, 3]}, {4, Subscript[x, 4]}}
```

---

Select Fridays from a time series with dates:

```wl
In[1]:=
ts = TemporalData[TimeSeries, {{{285.775791, 289.584598, 285.490482, 290.575565, 289.404423, 290.515507, 
    284.53455, 282.832828, 280.82584, 279.804813, 282.53754, 285.710728, 291.056065, 289.044041, 
    282.887882, 286.026035, 280.630649, 282.62262 ... 12000, 3549571200, 3549657600, 3549744000, 3549830400, 3549916800}}}, 1, 
  {"Continuous", 1}, {"Discrete", 1}, 1, {ValueDimensions -> 1, DateFunction -> Automatic, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, True, 314.1];

In[2]:= fridays = TimeSeriesWindow[ts, Friday]

Out[2]=
TemporalData[TimeSeries, {{{285.775791, 290.515507, 282.53754, 286.026035, 290.325321}}, 
  {{{3547497600, 3548102400, 3548707200, 3549312000, 3549916800}}}, 1, {"Continuous", 1}, 
  {"Discrete", 1}, 1, {ValueDimensions -> 1, DateFunction -> Automatic, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, True, 14.3]

In[3]:= DateListPlot[{ts, fridays}, Joined -> {True, False}, Filling -> 2 -> 0, FillingStyle -> Directive[Gray, Thick]]

Out[3]= [image]
```

---

Visualize different subsets of a time series:

```wl
In[1]:= data = TimeSeries[RandomFunction[ARIMAProcess[{.1}, 1, {.2}, 1], {1000}]];

In[2]:= ListLinePlot[data]

Out[2]= [image]
```

Split the data into three parts:

```wl
In[3]:=
win1 = TimeSeriesWindow[data, {Automatic, 300}];
win2 = TimeSeriesWindow[data, {300, 700}];
win3 = TimeSeriesWindow[data, {700, Automatic}];

In[4]:= ListLinePlot[{win1, win2, win3}, PlotLegends -> {"win1", "win2", "win3"}]

Out[4]= [image]
```

#### Data Types (5)

Extract three elements from a vector:

```wl
In[1]:= v = {a, b, c, d, e};

In[2]:= TimeSeriesWindow[v, {2, 4}]

Out[2]= {c, d, e}
```

---

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

```wl
In[1]:= v = {{1, a}, {3, b}, {7, c}, {14, d}, {15, e}};

In[2]:= TimeSeriesWindow[v, {2, 8}]

Out[2]= {{3, b}, {7, c}}
```

---

Extract 50 values from a ``TimeSeries`` :

```wl
In[1]:= ts = TemporalData[TimeSeries, {CompressedData["«1176»"], {{0, 99, 1}}, 1, {"Discrete", 1}, {"Discrete", 1}, 1, {}}, False, 10.];

In[2]:= win = TimeSeriesWindow[ts, {10, 59}]

Out[2]=
TemporalData[TimeSeries, {CompressedData["«612»"], {{10, 59, 1}}, 1, {"Discrete", 1}, 
  {"Discrete", 1}, 1, {}}, False, 10.]
```

Overlay the window over the original data:

```wl
In[3]:= ListLinePlot[{ts, win}]

Out[3]= [image]
```

---

Extract 30 values from an ``EventSeries`` :

```wl
In[1]:=
es = TemporalData[EventSeries, {{{-1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 
    -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 
    -1, -1, -1}}, {{0, 49, 1}}, 1, {"Discrete", 1}, {"Discrete", 1}, 1, 
  {ResamplingMethod -> None}}, False, 10.];

In[2]:= win = TimeSeriesWindow[es, {10, 39}]

Out[2]=
TemporalData[EventSeries, {{{1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 
    -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1}}, {{10, 39, 1}}, 1, {"Discrete", 1}, {"Discrete", 1}, 1, 
  {ResamplingMethod -> None}}, False, 10.]
```

Overlay the window over the original data:

```wl
In[3]:= ListPlot[{es, win}, Filling -> Axis]

Out[3]= [image]
```

---

Restrict the paths of ``TemporalData`` to a smaller interval:

```wl
In[1]:= td = RandomFunction[WienerProcess[], {0, 20, 0.01}, 5]

Out[1]=
TemporalData[Automatic, {CompressedData["«107648»"], {{0, 20, 0.01}}, 5, {"Continuous", 5}, 
  {"Continuous", 1}, 1, {ValueDimensions -> 1, ResamplingMethod -> 
    {"Interpolation", InterpolationOrder -> 1}}}, False, 14.3]

In[2]:= win = TimeSeriesWindow[td, {3, 15}]

Out[2]=
TemporalData[Automatic, {CompressedData["«64936»"], {{3., 15., 0.01}}, 5, {"Continuous", 5}, 
  {"Continuous", 1}, 1, {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, 
   ValueDimensions -> 1}}, False, 14.3]

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

Out[3]= {[image], [image]}
```

### Options (4)

#### IncludeWindowTimes (1)

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

```wl
In[1]:= ts = {{1, 1}, {2, 2}, {3, 3}, {4, 4}};

In[2]:= TimeSeriesWindow[ts, {2, 3}]

Out[2]= {{2, 2}, {3, 3}}
```

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

```wl
In[3]:= TimeSeriesWindow[ts, {1.5, 3.5}]

Out[3]= {{2, 2}, {3, 3}}
```

Specify that window times should be included:

```wl
In[4]:= TimeSeriesWindow[ts, {1.5, 3.5}, IncludeWindowTimes -> True]

Out[4]= {{1.5, 1}, {2, 2}, {3, 3}, {3.5, 3}}
```

Include only the right window time:

```wl
In[5]:= TimeSeriesWindow[ts, {1.5, 3.5}, IncludeWindowTimes -> {False, True}]

Out[5]= {{2, 2}, {3, 3}, {3.5, 3}}
```

#### ResamplingMethod (1)

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

```wl
In[1]:=
s = {Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4]};
t = {2, 4, 6, 8};

In[2]:=
td = TemporalData[s, {t}];
td//Normal

Out[2]= {{{2, Subscript[x, 1]}, {4, Subscript[x, 2]}, {6, Subscript[x, 3]}, {8, Subscript[x, 4]}}}
```

By default, a resampling method of the input data is used:

```wl
In[3]:= win1 = TimeSeriesWindow[td, {4, 6.4}, IncludeWindowTimes -> True];

In[4]:= win1//Normal

Out[4]= {{{4., Subscript[x, 2]}, {6., Subscript[x, 3]}, {6.4, Subscript[x, 3]}}}
```

Use interpolation of order 1:

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

In[6]:= win2//Normal

Out[6]= {{{4., Subscript[x, 2]}, {6., Subscript[x, 3]}, {6.4, 0.8 (Subscript[x, 3] - Subscript[x, 4]) + Subscript[x, 4]}}}
```

Use a fixed constant:

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

In[8]:= win3//Normal

Out[8]= {{{4., Subscript[x, 2]}, {6., Subscript[x, 3]}, {6.4, c}}}
```

#### CalendarType (1)

Use the Jewish calendar:

```wl
In[1]:= 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}};

In[2]:= TimeSeriesWindow[data, "Weekend", CalendarType -> "Jewish"]

Out[2]= {{DateObject[{9537, 10, 4, 0, 0, 0.}, "Instant", "Jewish", -6.], 1}, {DateObject[{9537, 10, 5, 0, 0, 0.}, "Instant", "Jewish", -6.], 2}}
```

#### HolidayCalendar (1)

Extract business days:

```wl
In[1]:= ts = TimeSeries[Range[20], {{2017, 4, 10}}];

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

Out[2]=
TemporalData[TimeSeries, {{{1, 2, 3, 4, 9, 10, 11, 12, 15, 16, 17, 18, 19}}, 
  {{{3700771200, 3700857600, 3700944000, 3701030400, 3701462400, 3701548800, 3701635200, 
     3701721600, 3701980800, 3702067200, 3702153600, 3702240000, 3702326400}}}, 1, 
  {"Continuous", 1}, {"Discrete", 1}, 1, 
  {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, True, 314.1]

In[3]:= DateListPlot[{ts, res}, Joined -> False, Filling -> 2 -> 0]

Out[3]= [image]
```

### Applications (2)

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

```wl
In[1]:=
stepdata = TemporalData[TimeSeries, {CompressedData["«674»"], {TemporalData`DateSpecification[{2013, 4, 1, 0, 0, 0.}, {2013, 9, 1, 0, 0, 0.}, 
    {1, "Day"}]}, 1, {"Discrete", 1}, {"Discrete", 1}, 1, {ValueDimensions -> 1}}, True, 10.];
```

Display the daily step counts for each of the months:

```wl
In[2]:= monthlyTS = Table[TimeSeriesWindow[stepdata, DateObject[{2013, k}]], {k, 4, 8}];

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

Out[3]= [image]
```

Display the total number of steps for each month:

```wl
In[4]:= monthlyTotals = Total /@ monthlyTS;

In[5]:= PieChart[monthlyTotals, ChartLabels -> Placed[{monthlyTotals, months}, {"RadialCenter", "RadialCallout"}]]

Out[5]= [image]
```

---

Visualize the temperature in Champaign during the summer of 2014:

```wl
In[1]:=
td = TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{365}, 
     {{-2.94, -7.28, -14.94, -3.39, -2.56, -21, -23.06, -14.33, -6.5, 1.33, 3.22, 1.67, 5, -1.72, 
       -2.33, -7.78, -0.5, -9, -4.28, 1.83, -0.94, -17, -12.17, -18 ... cation[{2014, 1, 1, 0, 0, 0.}, {2014, 12, 31, 0, 0, 0.}, {1, "Day"}]}, 
  1, {"Continuous", 1}, {"Discrete", 1}, 1, {ValueDimensions -> 1, DateFunction -> Automatic, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, True, 10.1];
```

Extract the temperatures for summer months:

```wl
In[2]:= summer = TimeSeriesWindow[td, {DateObject[{2014, 6, 1}, "Day", "Gregorian", -6.], DateObject[{2014, 9, 1}, "Day", "Gregorian", -6.]}]

Out[2]=
TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{93}, 
     {{23.83, 22.44, 25.17, 23.44, 17.67, 19, 21.22, 20, 17.5, 20.11, 19.11, 18.94, 19.28, 16.28, 
       17.11, 25, 26.22, 26.22, 26.44, 24.94, 22.33, 21.22, 23.17, 2 ... on[{2014, 6, 1, 0, 0, 0.}, {2014, 9, 1, 0, 0, 0.}, 
    {1, "Day"}]}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {ValueDimensions -> 1, DateFunction -> Automatic, ResamplingMethod -> 
    {"Interpolation", InterpolationOrder -> 1}}}, True, 10.1]
```

Find some basic descriptive statistics:

```wl
In[3]:= {Min[#], Mean[#], Max[#]}&@summer

Out[3]= {Quantity[14.67, "DegreesCelsius"], Quantity[21.293440860215053, "DegreesCelsius"], Quantity[26.44, "DegreesCelsius"]}

In[4]:= DateListPlot[{td, summer}, FrameLabel -> Automatic]

Out[4]= [image]
```

## See Also

* [`MovingMap`](https://reference.wolfram.com/language/ref/MovingMap.en.md)
* [`TimeSeriesAggregate`](https://reference.wolfram.com/language/ref/TimeSeriesAggregate.en.md)
* [`TimeSeriesResample`](https://reference.wolfram.com/language/ref/TimeSeriesResample.en.md)
* [`TimeSeriesThread`](https://reference.wolfram.com/language/ref/TimeSeriesThread.en.md)
* [`RegularlySampledQ`](https://reference.wolfram.com/language/ref/RegularlySampledQ.en.md)
* [`MinimumTimeIncrement`](https://reference.wolfram.com/language/ref/MinimumTimeIncrement.en.md)
* [`TimeSeriesShift`](https://reference.wolfram.com/language/ref/TimeSeriesShift.en.md)
* [`TimeSeriesRescale`](https://reference.wolfram.com/language/ref/TimeSeriesRescale.en.md)
* [`TimeSeriesMap`](https://reference.wolfram.com/language/ref/TimeSeriesMap.en.md)
* [`TimeSeriesMapThread`](https://reference.wolfram.com/language/ref/TimeSeriesMapThread.en.md)
* [`TimeSeriesInsert`](https://reference.wolfram.com/language/ref/TimeSeriesInsert.en.md)
* [`TimeSeriesModelFit`](https://reference.wolfram.com/language/ref/TimeSeriesModelFit.en.md)
* [`TemporalData`](https://reference.wolfram.com/language/ref/TemporalData.en.md)
* [`TimeSeries`](https://reference.wolfram.com/language/ref/TimeSeries.en.md)
* [`EventSeries`](https://reference.wolfram.com/language/ref/EventSeries.en.md)
* [`ResamplingMethod`](https://reference.wolfram.com/language/ref/ResamplingMethod.en.md)
* [`IncludeWindowTimes`](https://reference.wolfram.com/language/ref/IncludeWindowTimes.en.md)

## Related Guides

* [Time Series Processing](https://reference.wolfram.com/language/guide/TimeSeries.en.md)

## History

* [Introduced in 2014 (10.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn100.en.md) \| [Updated in 2019 (12.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn120.en.md)