---
title: "TimeSeriesResample"
language: "en"
type: "Symbol"
summary: "TimeSeriesResample[tseries] uniformly resamples tseries according to its minimum time increment. TimeSeriesResample[tseries, rspec] resamples tseries according to rspec."
keywords: 
- downsample time series
- upsample time series
- regularize time series
- sample time series
- time series sampling
- time series part
- time series select
canonical_url: "https://reference.wolfram.com/language/ref/TimeSeriesResample.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Time Series Processing"
    link: "https://reference.wolfram.com/language/guide/TimeSeries.en.md"
  - 
    title: "Signal Processing"
    link: "https://reference.wolfram.com/language/guide/SignalProcessing.en.md"
  - 
    title: "Creating & Importing Signals"
    link: "https://reference.wolfram.com/language/guide/CreatingAndImportingSignals.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: "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: "TimeSeriesWindow"
    link: "https://reference.wolfram.com/language/ref/TimeSeriesWindow.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"
---
# TimeSeriesResample

TimeSeriesResample[tseries] uniformly resamples tseries according to its minimum time increment.

TimeSeriesResample[tseries, rspec] resamples tseries according to rspec.

## Details and Options

* ``TimeSeriesResample`` is often used to convert irregular time series to regular ones. It can also be used to align time series.

* [image]

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

* Some basic settings for ``rspec`` include:

|                                                                                   |                                    |
| --------------------------------------------------------------------------------- | ---------------------------------- |
| dt                                                                                | use uniform times with spacing dt  |
| $$\left\{\text{\textit{$t$}}_0,\text{\textit{$t$}}_1,\text{\textit{dt}}\right\}$$ | use times t0 to t1 with spacing dt |
| {{t1, t2, …}}                                                                     | use explicit times {t1, t2, …}     |
| dayspec                                                                           | use day specification              |

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

* If ``dt`` is set to ``Automatic``, the minimum time increment in ``tseries`` is used.

* The following settings for ``rspec`` are useful if ``tseries`` contains multiple paths:

|                |                                  |
| -------------- | -------------------------------- |
| "Union"        | use all times present in tseries |
| "Intersection" | use times common to all paths    |
| {"Times", p}   | use times from path p            |

* If times are not given, then ``tseries`` is assumed to be regular with unit spacing.

* ``TimeSeriesResample`` takes the following option:

|                   |                             |                                                 |
| ----------------- | --------------------------- | ----------------------------------------------- |
| ResamplingMethod  | Automatic                   | the method to use for resampling paths          |
| CalendarType      | "Gregorian"                 | the calendar system to interpret the dates      |
| HolidayCalendar   | {"UnitedStates", "Default"} | the holiday calendar schedule for business days |
| TimeZone          | Automatic                   | the time zone specification for dates           |

---

## Examples (28)

### Basic Examples (3)

Resample a time series:

```wl
In[1]:= ts = TimeSeries[RandomReal[1, 5], {0}]

Out[1]=
TemporalData[TimeSeries, {{{0.44924073385004903, 0.07424173481435048, 0.20477702140693843, 
    0.048015767042255186, 0.4951144908193783}}, {{0, 4, 1}}, 1, {"Continuous", 1}, {"Discrete", 1}, 
  1, {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 314.1]
```

Resampling with spacing smaller than the minimum time increment will add time stamps:

```wl
In[2]:= ts["MinimumTimeIncrement"]

Out[2]= {1}

In[3]:= res1 = TimeSeriesResample[ts, 1 / 3]

Out[3]=
TemporalData[TimeSeries, {{{0.44924073385004903, 0.3242410675048162, 0.19924140115958333, 
    0.07424173481435048, 0.11775349701187979, 0.16126525920940912, 0.20477702140693843, 
    0.152523269952044, 0.10026951849714963, 0.048015767042255186, 0.19704867496796297, 
    0.3460815828936705, 0.4951144908193783}}, {{0, 4, Rational[1, 3]}}, 1, {"Continuous", 1}, 
  {"Discrete", 1}, 1, {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 
 314.1]

In[4]:= ListPlot[{ts, res1}, Joined -> {True, False}, Filling -> {2 -> 0}]

Out[4]= [image]
```

Resampling with spacing larger than the minimum time increment:

```wl
In[5]:= res2 = TimeSeriesResample[ts, 2]

Out[5]=
TemporalData[TimeSeries, {{{0.44924073385004903, 0.20477702140693843, 0.4951144908193783}}, 
  {{0, 4, 2}}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 314.1]

In[6]:= ListPlot[{ts, res2}, Joined -> {True, False}, Filling -> {2 -> 0}]

Out[6]= [image]
```

---

Resample time series with dates:

```wl
In[1]:= ts = TimeSeries[Range[20], {{2016, 5, 30, 3, 10, 1.}, Automatic, "Day"}]

Out[1]=
TemporalData[TimeSeries, {{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 
    20}}, {TemporalData`DateSpecification[{2016, 5, 30, 3, 10, 1.}, {2016, 6, 18, 3, 10, 1}, 
    {1, "Day"}]}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, True, 314.1]
```

Select business days:

```wl
In[2]:= res1 = TimeSeriesResample[ts, "BusinessDay"]

Out[2]=
TemporalData[TimeSeries, {{{Rational[161399, 86400], Rational[247799, 86400], 
    Rational[334199, 86400], Rational[420599, 86400], Rational[679799, 86400], 
    Rational[766199, 86400], Rational[852599, 86400], Rational[938999, 86400], 
    Ratio ... , 
  {TemporalData`DateSpecification[{2016, 5, 30, 3, 10, 1.}, {2016, 6, 18, 3, 10, 1.}, 
    "BusinessDay", "DayRange"]}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, True, 314.1]

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

Out[3]= [image]
```

Select weekends:

```wl
In[4]:= res2 = TimeSeriesResample[ts, "Weekend"]

Out[4]=
TemporalData[TimeSeries, {{{6, 7, 13, 14, 20}}, 
  {TemporalData`DateSpecification[{2016, 5, 30, 3, 10, 1.}, {2016, 6, 18, 3, 10, 1.}, "Weekend", 
    "DayRange"]}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, True, 314.1]

In[5]:= DayName /@ res2["Dates"]

Out[5]= {Saturday, Sunday, Saturday, Sunday, Saturday}
```

Select Wednesdays:

```wl
In[6]:= res3 = TimeSeriesResample[ts, Wednesday]

Out[6]=
TemporalData[TimeSeries, {{{3, 10, 17}}, {TemporalData`DateSpecification[{2016, 5, 30, 3, 10, 1.}, 
    {2016, 6, 18, 3, 10, 1.}, Wednesday, "DayRange"]}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, True, 314.1]

In[7]:= res3//Normal

Out[7]= {{DateObject[{2016, 6, 1, 3, 10, 1.}, "Instant", "Gregorian", -6.], 3}, {DateObject[{2016, 6, 8, 3, 10, 1.}, "Instant", "Gregorian", -6.], 10}, {DateObject[{2016, 6, 15, 3, 10, 1.}, "Instant", "Gregorian", -6.], 17}}
```

---

Resample an irregular data:

```wl
In[1]:= data = RandomFunction[PoissonProcess[.3], {1, 50}];

In[2]:= ListPlot[data]

Out[2]= [image]

In[3]:= RegularlySampledQ[data]

Out[3]= False
```

Resample with step of 2:

```wl
In[4]:= rdata = TimeSeriesResample[data, 2];

In[5]:= ListPlot[rdata]

Out[5]= [image]
```

The resampled time series is now regularly sampled:

```wl
In[6]:= RegularlySampledQ[rdata]

Out[6]= True
```

### Scope (13)

#### Basic Uses (3)

Downsample a time series:

```wl
In[1]:= data = RandomFunction[PoissonProcess[30], {1, 5}];

In[2]:= ListPlot[data]

Out[2]= [image]

In[3]:= data["PathLength"]

Out[3]= 114
```

Resample at a granularity of 0.25:

```wl
In[4]:= ds = TimeSeriesResample[data, .25];

In[5]:= ListPlot[ds]

Out[5]= [image]

In[6]:= ds["PathLength"]

Out[6]= 17
```

---

Sample multiple paths at the same time:

```wl
In[1]:= data = RandomFunction[PoissonProcess[10], {1, 5}, 20];

In[2]:= ListPlot[data]

Out[2]= [image]
```

Resample at a granularity of 0.1:

```wl
In[3]:= ds = TimeSeriesResample[data, 0.1];

In[4]:= ListPlot[ds]

Out[4]= [image]
```

---

Fill in missing values:

```wl
In[1]:= appl = FinancialData["APPLX", {"January 2013", "March 2013"}];

In[2]:= RegularlySampledQ[appl]

Out[2]= False
```

Resample at a daily resolution, interpolating holidays and weekends:

```wl
In[3]:= applR = TimeSeriesResample[appl, "Day"];

In[4]:= RegularlySampledQ[applR]

Out[4]= True

In[5]:= DateListPlot[applR, Joined -> True]

Out[5]= [image]
```

Alternatively, insert ``Missing`` :

```wl
In[6]:= applM = TimeSeriesResample[appl, "Day", ResamplingMethod -> None];

In[7]:= DateListPlot[applM, Joined -> True]

Out[7]= [image]
```

#### Data Types (6)

Resample a time series in the form of a vector:

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

Upsample by a factor of 2:

```wl
In[2]:= TimeSeriesResample[data, 1 / 2]

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

Downsample by a factor of 2:

```wl
In[3]:= TimeSeriesResample[data, 2]

Out[3]= {Subscript[x, 1], Subscript[x, 3], Subscript[x, 5]}
```

---

A time series given as time-value pairs:

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

Upsample by a factor of 2:

```wl
In[2]:= TimeSeriesResample[data, 1 / 2]

Out[2]= {{1, Subscript[x, 1]}, {(3/2), Subscript[x, 1]}, {2, Subscript[x, 2]}, {(5/2), Subscript[x, 2]}, {3, Subscript[x, 3]}, {(7/2), Subscript[x, 3]}, {4, Subscript[x, 4]}, {(9/2), Subscript[x, 4]}, {5, Subscript[x, 5]}}
```

Downsample by a factor of 2:

```wl
In[3]:= TimeSeriesResample[data, 2]

Out[3]= {{1, Subscript[x, 1]}, {3, Subscript[x, 3]}, {5, Subscript[x, 5]}}
```

---

Resample a ``TimeSeries`` :

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

Upsample by a factor of 2:

```wl
In[2]:= TimeSeriesResample[data, 1 / 2]["Path"]

Out[2]= {{1, Subscript[x, 1]}, {(3/2), Subscript[x, 1]}, {2, Subscript[x, 2]}, {(5/2), Subscript[x, 2]}, {3, Subscript[x, 3]}, {(7/2), Subscript[x, 3]}, {4, Subscript[x, 4]}, {(9/2), Subscript[x, 4]}, {5, Subscript[x, 5]}}
```

Downsample by a factor of 2:

```wl
In[3]:= TimeSeriesResample[data, 2]["Path"]

Out[3]= {{1, Subscript[x, 1]}, {3, Subscript[x, 3]}, {5, Subscript[x, 5]}}
```

---

Resample an ``EventSeries`` :

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

By default, an event series is not interpolated:

```wl
In[2]:= TimeSeriesResample[data, 1 / 2]["Path"]

Out[2]= {{1, Subscript[x, 1]}, {(3/2), Missing[]}, {2, Subscript[x, 2]}, {(5/2), Missing[]}, {3, Subscript[x, 3]}, {(7/2), Missing[]}, {4, Subscript[x, 4]}, {(9/2), Missing[]}, {5, Subscript[x, 5]}}
```

Setting the ``ResamplingMethod`` overrides this:

```wl
In[3]:= TimeSeriesResample[data, 1 / 2, ResamplingMethod -> {"Constant", c}]["Path"]

Out[3]= {{1, Subscript[x, 1]}, {(3/2), c}, {2, Subscript[x, 2]}, {(5/2), c}, {3, Subscript[x, 3]}, {(7/2), c}, {4, Subscript[x, 4]}, {(9/2), c}, {5, Subscript[x, 5]}}
```

---

A single path given as ``TemporalData`` :

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

Upsample by a factor of 2:

```wl
In[2]:= TimeSeriesResample[data, 1 / 2]["Path"]

Out[2]= {{1, Subscript[x, 1]}, {(3/2), Subscript[x, 1]}, {2, Subscript[x, 2]}, {(5/2), Subscript[x, 2]}, {3, Subscript[x, 3]}, {(7/2), Subscript[x, 3]}, {4, Subscript[x, 4]}, {(9/2), Subscript[x, 4]}, {5, Subscript[x, 5]}}
```

Downsample by a factor of 2:

```wl
In[3]:= TimeSeriesResample[data, 2]["Path"]

Out[3]= {{1, Subscript[x, 1]}, {3, Subscript[x, 3]}, {5, Subscript[x, 5]}}
```

---

Multiple paths given as ``TemporalData`` :

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

Upsample by a factor of 2:

```wl
In[2]:= TimeSeriesResample[data, .5]["Paths"]

Out[2]= {{{1., Subscript[x, 1]}, {1.5, Subscript[x, 1]}, {2., Subscript[x, 2]}, {2.5, Subscript[x, 2]}, {3., Subscript[x, 3]}, {3.5, Subscript[x, 3]}, {4., Subscript[x, 4]}, {4.5, Subscript[x, 4]}, {5., Subscript[x, 5]}}, {{1., Subscript[y, 1]}, {1.5, Subscript[y, 1]}, {2., Subscript[y, 2]}, {2.5, Subscript[y, 2]}, {3., Subscript[y, 3]}, {3.5, Subscript[y, 3]}, {4., Subscript[y, 4]}, {4.5, Subscript[y, 4]}, {5., Subscript[y, 5]}}}
```

Downsample by a factor of 2:

```wl
In[3]:= TimeSeriesResample[data, 2]["Paths"]

Out[3]= {{{1, Subscript[x, 1]}, {3, Subscript[x, 3]}, {5, Subscript[x, 5]}}, {{1, Subscript[y, 1]}, {3, Subscript[y, 3]}, {5, Subscript[y, 5]}}}
```

---

#### Sampling (4)

Resample according to the smallest time increment:

```wl
In[1]:= data = RandomFunction[PoissonProcess[3], {1, 100}];

In[2]:= rdata = TimeSeriesResample[data];
```

The original data is irregular:

```wl
In[3]:= RegularlySampledQ[data]

Out[3]= False

In[4]:= mti1 = Min[Differences[data["Times"]]]

Out[4]= 0.00126246
```

Resampling gives regular data with the same minimum time increment:

```wl
In[5]:= RegularlySampledQ[rdata]

Out[5]= True

In[6]:= mti2 = Min[Differences[rdata["Times"]]]

Out[6]= 0.00126246

In[7]:= mti1 == mti2

Out[7]= True
```

---

Specify a sampling increment of 3:

```wl
In[1]:= data = RandomFunction[PoissonProcess[3], {1, 100}];

In[2]:= ListPlot[TimeSeriesResample[data, 3]]

Out[2]= [image]
```

Larger values give coarser sampling:

```wl
In[3]:= Table[ListPlot[TimeSeriesResample[data, dt], PlotLabel -> dt], {dt, {1, 5, 10}}]

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

---

Use a sampling increment based in calendar time:

```wl
In[1]:= data = FinancialData["APPLX", "2010"];

In[2]:= DateListPlot[data]

Out[2]= [image]

In[3]:= DateListPlot[TimeSeriesResample[data, {2, "Month"}]]

Out[3]= [image]
```

---

Resample multiple paths:

```wl
In[1]:= td = TemporalData[{{{1, x1}, {2, x2}, {2.1, x3}, {3, x4}, {4, x5}}, {{1, y1}, {1.5, y2}, {2, y3}, {2.5, y4}, {3, y5}, {3.5, y6}, {4, y7}}}];
```

Use the union of times:

```wl
In[2]:= TimeSeriesResample[td, "Union"]["Times"]

Out[2]= {1, (3/2), 2, 2.1, (5/2), 3, (7/2), 4}
```

The intersection:

```wl
In[3]:= TimeSeriesResample[td, "Intersection"]["Times"]

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

Use times from the first path:

```wl
In[4]:= TimeSeriesResample[td, {"Times", 1}]["Times"]

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

### Options (6)

#### ResamplingMethod (3)

Resample irregular data using linear interpolation:

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

In[2]:= TimeSeriesResample[data, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}]["Path"]

Out[2]= {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, (13/3)}, {6, (14/3)}, {7, 5}}
```

By default, the method setting for the data is used:

```wl
In[3]:= data = TimeSeries[{1, 2, 3, 4, 5}, {{1, 2, 3, 4, 7}}, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}];

In[4]:= TimeSeriesResample[data]["Path"]

Out[4]= {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, (13/3)}, {6, (14/3)}, {7, 5}}
```

---

Setting ``ResamplingMethod`` to ``None`` gives missing values for irregular data:

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

In[2]:= TimeSeriesResample[data, ResamplingMethod -> None]["Path"]

Out[2]= {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, Missing[]}, {6, Missing[]}, {7, 5}}
```

---

Use a constant value:

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

In[2]:= TimeSeriesResample[data, ResamplingMethod -> {"Constant", c}]["Path"]

Out[2]= {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, c}, {6, c}, {7, 5}}
```

#### CalendarType (1)

The time series of stock prices:

```wl
In[1]:=
stocks = FinancialData["TXN", "Close", {{2015, 1, 1}, {2015, 6, 30}}];
data = TimeSeries[stocks]

Out[1]=
TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{124}, 
     {CompressedData["«670»"], 
      "USDollars", {{1}}}]]}, CompressedData["«696»"], 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {DateFunction -> Automatic, MetaInformation -> {"FinancialProperty" -> "Close"}, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, TemporalRegularity -> Automatic, 
   ValueDimensions -> 1}}, True, 14.3]
```

Resample using Islamic calendar:

```wl
In[2]:= res = TimeSeriesResample[data, CalendarType -> "Islamic"]

Out[2]=
TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{177}, 
     {CompressedData["«1012»"], "USDollars", {{1}}}]]}, 
  {TemporalData`DateSpecification[{2015, 1, 2, 0, 0, 0}, {2015, 6, 30, 0, 0, 0}, {1, "Day"}]}, 1, 
  {"Contin ... ndarType -> "Islamic", DateFunction -> Automatic, 
   MetaInformation -> {"FinancialProperty" -> "Close"}, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, TemporalRegularity -> Automatic, 
   ValueDimensions -> 1}}, True, 14.3]

In[3]:= res["Dates"][[ ;; 3]]

Out[3]= {DateObject[{1436, 3, 11, 0, 0, 0}, "Instant", "Islamic", -5.], DateObject[{1436, 3, 12, 0, 0, 0}, "Instant", "Islamic", -5.], DateObject[{1436, 3, 13, 0, 0, 0}, "Instant", "Islamic", -5.]}
```

#### HolidayCalendar (1)

The time series of stock prices:

```wl
In[1]:=
stocks = FinancialData["AAPL", "Close", {{2015, 1, 1}, {2015, 6, 30}}];
data = TimeSeries[stocks]

Out[1]=
TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{124}, 
     {CompressedData["«674»"], 
      "USDollars", {{1}}}]]}, CompressedData["«696»"], 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {DateFunction -> Automatic, MetaInformation -> {"FinancialProperty" -> "Close"}, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, TemporalRegularity -> Automatic, 
   ValueDimensions -> 1}}, True, 14.3]
```

Resample according to business days in United States:

```wl
In[2]:= res1 = TimeSeriesResample[data, "BusinessDay", HolidayCalendar -> "UnitedStates"]

Out[2]=
TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{125}, 
     {CompressedData["«674»"], 
      "USDollars", {{1}}}]]}, {TemporalData`DateSpecification[{2015, 1, 2, 0, 0, 0}, 
    {2015, 6, 30, 0, 0, 0}, "BusinessDay", "DayR ...  -> Automatic, HolidayCalendar -> "UnitedStates", 
   MetaInformation -> {"FinancialProperty" -> "Close"}, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, TemporalRegularity -> Automatic, 
   ValueDimensions -> 1}}, True, 14.3]
```

Resample according to business days at New York Stock Exchange:

```wl
In[3]:= res2 = TimeSeriesResample[data, "BusinessDay", HolidayCalendar -> {"UnitedStates", "NYSE"}]

Out[3]=
TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{124}, 
     {CompressedData["«674»"], 
      "USDollars", {{1}}}]]}, {TemporalData`DateSpecification[{2015, 1, 2, 0, 0, 0}, 
    {2015, 6, 30, 0, 0, 0}, "BusinessDay", "DayR ... tic, HolidayCalendar -> {"UnitedStates", "NYSE"}, 
   MetaInformation -> {"FinancialProperty" -> "Close"}, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, TemporalRegularity -> Automatic, 
   ValueDimensions -> 1}}, True, 14.3]
```

Find the one business day NYSE was closed:

```wl
In[4]:= {d} = Complement[res1["Dates"], res2["Dates"]]

Out[4]= {DateObject[{2015, 4, 3, 0, 0, 0}, "Instant", "Gregorian", -5.]}
```

The holiday observed by NYSE:

```wl
In[5]:= WolframAlpha[DateString[d, "Date"], {{"ObservanceDate (country)", 1}, "ComputableData"}]

Out[5]= Missing["NotAvailable"]
```

#### TimeZone (1)

The time series of stock prices:

```wl
In[1]:=
stocks = FinancialData["SBUX", "Close", {{2015, 1, 1}, {2015, 6, 30}}];
data = TimeSeries[stocks]

Out[1]=
TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{124}, 
     {CompressedData["«682»"]\
, "USDollars", {{1}}}]]}, CompressedData["«696»"], 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {DateFunction -> Automatic, MetaInformation -> {"FinancialProperty" -> "Close"}, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, TemporalRegularity -> Automatic, 
   ValueDimensions -> 1}}, True, 14.3]
```

The time series are not regularly sampled:

```wl
In[2]:= RegularlySampledQ[data]

Out[2]= False
```

Resample according to the NYSE business day in the time zone of New York City:

```wl
In[3]:= res = TimeSeriesResample[data, "BusinessDay", HolidayCalendar -> {"UnitedStates", "NYSE"}, TimeZone -> "America/New_York"]

Out[3]=
TimeSeriesResample[TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{124}, 
     {CompressedData["«686»"], "USDollars", {{1}}}]]}, CompressedData["«698»"], 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {DateFunction -> Autom ...  -> "Close"}, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, TemporalRegularity -> Automatic, 
   ValueDimensions -> 1}}, True, 14.3], "BusinessDay", HolidayCalendar -> {"UnitedStates", "NYSE"}, TimeZone -> "America/New_York"]

In[4]:= res["Dates"][[1]]

Out[4]= "Dates"
```

### Applications (5)

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.];
```

Analyze the number of steps depending on the day of the week:

```wl
In[2]:= weekdays = {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
```

Select the values for each day of the week:

```wl
In[3]:= wk = Map[TimeSeriesResample[stepdata, #]&, weekdays];
```

Compute the mean number of steps for each day of the week:

```wl
In[4]:= avg = Map[Floor[Mean[#]]&, wk];
```

Visualize the mean steps per day:

```wl
In[5]:= BarChart[avg, ChartStyle -> "DarkRainbow", LabelingFunction -> (Placed[#, Below]&), ChartLabels -> {avg, Placed[weekdays, Center, Style[Rotate[#, Pi / 2], 16, Bold, Opacity[1]]&]}]

Out[5]= [image]
```

---

Financial information is generated only for business days:

```wl
In[1]:= data = TimeSeries@FinancialData["SBUX", "Close", {{2013, 12, 1}, {2013, 12, 31}}]

Out[1]=
TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{21}, 
     {{40.53499984741211, 40.275001525878906, 39.75, 39.86000061035156, 39.970001220703125, 
       39.8650016784668, 38.689998626708984, 38.20000076293945, 38.2400016 ... }, {"Discrete", 1}, 1, 
  {DateFunction -> Automatic, MetaInformation -> {"FinancialProperty" -> "Close"}, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, TemporalRegularity -> Automatic, 
   ValueDimensions -> 1}}, True, 14.3]
```

The automatically created time series is not regularly sampled:

```wl
In[2]:= RegularlySampledQ[data]

Out[2]= False
```

Resample according to ``"BusinessDay"`` to create a uniformly sampled time series:

```wl
In[3]:= ts = TimeSeriesResample[data, "BusinessDay"]

Out[3]=
TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{21}, 
     {{40.53499984741211, 40.275001525878906, 39.75, 39.86000061035156, 39.970001220703125, 
       39.8650016784668, 38.689998626708984, 38.20000076293945, 38.2400016 ... }, {"Discrete", 1}, 1, 
  {DateFunction -> Automatic, MetaInformation -> {"FinancialProperty" -> "Close"}, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, TemporalRegularity -> Automatic, 
   ValueDimensions -> 1}}, True, 14.3]

In[4]:= RegularlySampledQ[ts]

Out[4]= True
```

The paths are the same:

```wl
In[5]:= data["Path"] == ts["Path"]

Out[5]= True
```

---

Consider some financial data:

```wl
In[1]:= data = TimeSeries@FinancialData["SBUX", "Close", {{2013, 12, 1}, {2013, 12, 31}}]

Out[1]=
TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{21}, 
     {{40.53499984741211, 40.275001525878906, 39.75, 39.86000061035156, 39.970001220703125, 
       39.8650016784668, 38.689998626708984, 38.20000076293945, 38.2400016 ... }, {"Discrete", 1}, 1, 
  {DateFunction -> Automatic, MetaInformation -> {"FinancialProperty" -> "Close"}, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, TemporalRegularity -> Automatic, 
   ValueDimensions -> 1}}, True, 14.3]
```

The data is generated only for business days. There are no changes on the remaining days; hence, we can resample by day by keeping the value from the left:

```wl
In[2]:= ts = TimeSeriesResample[data, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 0}]

Out[2]=
TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{30}, 
     {{40.53499984741211, 40.275001525878906, 39.75, 39.86000061035156, 39.970001220703125, 
       39.970001220703125, 39.970001220703125, 39.8650016784668, 38.689998 ... , {"Discrete", 1}, 1, {DateFunction -> Automatic, 
   MetaInformation -> {"FinancialProperty" -> "Close"}, 
   ResamplingMethod -> {"Interpolation", InterpolationOrder -> 0}, TemporalRegularity -> Automatic, 
   ValueDimensions -> 1}}, True, 14.3]
```

The plot is flat over the weekends and holidays:

```wl
In[3]:= DateListPlot[ts]

Out[3]= [image]
```

---

Use ``AirPressureData`` to examine pressure changes due to Hurricane Sandy at Long Island MacArthur Airport:

```wl
In[1]:= pressure = AirPressureData["KISP", {DateObject[{2012, 10, 26}], DateObject[{2012, 10, 30}]}]

Out[1]=
TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{115}, 
     {CompressedData["«168»"], 
      "InchesOfMercury", {{1}}}]]}, CompressedData["«548»"], 
  1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, ValueDimensions -> 1}}, True, 
 14.3]

In[2]:= DateListPlot[pressure, FrameLabel -> Automatic]

Out[2]= [image]
```

The data is not regularly sampled:

```wl
In[3]:= RegularlySampledQ[pressure]

Out[3]= False
```

To analyze the rate of change, data needs to be resampled into a regularly sampled time series:

```wl
In[4]:= res = TimeSeriesResample[pressure, {DateObject[{2012, 10, 27}], Automatic, "Hour"}]

Out[4]=
TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{72}, 
     {CompressedData["«228»"], "InchesOfMercury", {{1}}}]]}, 
  {TemporalData`DateSpecification[{2012, 10, 27, 0, 0, 0}, {2012, 10, 29, 23, 56, 0.}, 
    {1, "Hour"}]}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, ValueDimensions -> 1}}, True, 
 14.3]

In[5]:= RegularlySampledQ[res]

Out[5]= True
```

Plotting each observation disjointly shows the rate of change of the pressure, with larger spacing indicating faster changes:

```wl
In[6]:= DateListPlot[res, Joined -> False]

Out[6]= [image]
```

---

Analyze the monthly temperatures in Champaign during 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];
```

The raw data comes in one-day increments:

```wl
In[2]:= td["MinimumTimeIncrement"]

Out[2]= {{1, "Day"}}
```

Resample by a month:

```wl
In[3]:= monthlyTemps = TimeSeriesResample[td, {Automatic, Automatic, "Month"}]

Out[3]=
TemporalData[TimeSeries, 
 {{StructuredArray[QuantityArray, {12}, StructuredArray`StructuredData[QuantityArray, 
     {-2.9400000000000004, 0., -0.61, 10.33, 8.22, 23.83, 24.11, 20.94, 24.33, 16.78, 3.11, -1.61}, 
     "DegreesCelsius", {{1}}]]}, { ... 2014, 1, 1, 0, 0, 0.}, 
    {2014, 12, 31, 0, 0, 0.}, {1, "Month"}]}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, 
  {DateFunction -> Automatic, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, 
   ValueDimensions -> 1}}, True, 314.1]

In[4]:= monthlyTemps["MinimumTimeIncrement"]

Out[4]= {{1, "Month"}}
```

Basic descriptive statistics:

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

Out[5]= {Quantity[-2.9400000000000004, "DegreesCelsius"], Quantity[10.540833333333333, "DegreesCelsius"], Quantity[24.33, "DegreesCelsius"]}
```

Compare to the original data:

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

Out[6]= {Quantity[-23.06, "DegreesCelsius"], Quantity[9.01, "DegreesCelsius"], Quantity[26.44, "DegreesCelsius"]}

In[7]:= DateListPlot[{td, monthlyTemps}, PlotLegends -> {"daily temperatures", "resampled monthly"}, FrameLabel -> Automatic]

Out[7]= [image]
```

### Possible Issues (1)

The original time stamps may not be preserved after resampling:

```wl
In[1]:=
v = {1, 3, 9, 3, 2};
t = {0, .3, 1, 1.3, 2};
ts = TimeSeries[v, {t}]

Out[1]=
TemporalData[TimeSeries, {{{1, 3, 9, 3, 2}}, {{{0., 0.3, 1., 1.3, 2.}}}, 1, {"Continuous", 1}, 
  {"Discrete", 1}, 1, {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, 
   ValueDimensions -> 1}}, False, 14.3]
```

Note that the time series is not regularly sampled:

```wl
In[2]:= RegularlySampledQ[ts]

Out[2]= False
```

Resample according to ``MinimumTimeIncrement`` :

```wl
In[3]:= ts1 = TimeSeriesResample[ts]

Out[3]=
TemporalData[TimeSeries, {{{1., 3., 5.571428571428571, 8.142857142857142, 5.000000000000002, 
    2.7142857142857144, 2.285714285714286}}, {{0., 1.7999999999999998, 0.3}}, 1, {"Continuous", 1}, 
  {"Discrete", 1}, 1, {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, 
   ValueDimensions -> 1}}, False, 14.3]
```

New times:

```wl
In[4]:= ts1["Times"]

Out[4]= {0., 0.3, 0.6, 0.9, 1.2, 1.5, 1.8}
```

## See Also

* [`MovingMap`](https://reference.wolfram.com/language/ref/MovingMap.en.md)
* [`TimeSeriesAggregate`](https://reference.wolfram.com/language/ref/TimeSeriesAggregate.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)
* [`TimeSeriesWindow`](https://reference.wolfram.com/language/ref/TimeSeriesWindow.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)

## Related Guides

* [Time Series Processing](https://reference.wolfram.com/language/guide/TimeSeries.en.md)
* [Signal Processing](https://reference.wolfram.com/language/guide/SignalProcessing.en.md)
* [Creating & Importing Signals](https://reference.wolfram.com/language/guide/CreatingAndImportingSignals.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)