TimeSeriesMap[f,tes]
creates a new time series with time-value pairs {t,f[x]} for each pair {t,x} of the time or event series data tes.
TimeSeriesMap[{ncom1f1,ncom2f2,…},tes]
constructs a new time series with the same timestamps and components ncomi, each obtained by applying the function fi to the values of tes.
TimeSeriesMap
TimeSeriesMap[f,tes]
creates a new time series with time-value pairs {t,f[x]} for each pair {t,x} of the time or event series data tes.
TimeSeriesMap[{ncom1f1,ncom2f2,…},tes]
constructs a new time series with the same timestamps and components ncomi, each obtained by applying the function fi to the values of tes.
Details
- TimeSeriesMap is typically used to derive new components from existing ones, e.g. a rate by dividing two components.
- Possible forms of time or event series data tes include:
-
TimeSeries[…] continuous time-ordered sampled data EventSeries[…] collection of temporal events with values TemporalData[…] one or more paths composed of time-value pairs {{t1,x1},{t2,x2},…} list of time-value pairs {x1,x2,…} list of values with implied integer times starting at 0 - A component "com" in a time series tes can be used as an argument to the mapped function f using the syntax f[…,#com,…]&. »
- For a simple time series with no named components, values can be accessed using either f[…,#,…]& or f[…,#Value,…]&. »
- For any time series, #Timestamp may be used to pass the timestamp as an argument in the mapped function f.
- TimeSeriesMap[cspec,tes] is effectively equivalent to Head[tes][ConstructColumns[Tabular[tes],cspec],{ tes["Times"]}]. »
- TimeSeriesMap threads pathwise for TemporalData objects with multiple paths.
Examples
open all close allBasic Examples (2)
Map a function f over the values in a time series:
TimeSeries[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5]}, {1}]TimeSeriesMap[f, %]%//NormalSpecify the value components to use as function arguments in a multicomponent time series:
TimeSeries[{"a" -> {11, 17, 13}, "b" -> {"cat", "dog", "fox"}, "c" -> {.1, .5, .9}}, {0}]TimeSeriesMap[#a + #c&, %]%//TabularScope (16)
Basic Uses (6)
Map over a simple time series:
TimeSeries[{23, 34, 56}, {0}]TimeSeriesMap[f, %]//NormalMap over a simple time series with list type values:
TimeSeries[Array[x, {2, 3}], {0}]TimeSeriesMap[f, %]//NormalMap over a time series with one component:
ts = TimeSeries[{23, 34, 56}, {0}, ComponentKeys -> {"a"}]TimeSeriesMap[f, ts]//TabularUse the component name to map over the corresponding values of the associations:
TimeSeriesMap[f[#a]&, ts]//TabularMap over a time series with multiple components:
ts = TimeSeries[{"a" -> {11, 17, 13}, "b" -> {"cat", "dog", "fox"}, "c" -> {.1, .5, .9}}, {0}]TimeSeriesMap[f[#]&, ts]//NormalTimeSeriesMap[f[#Timestamp]&, ts]//NormalTimeSeriesMap[f[#[[3]]]&, ts]//NormalAlternatively use the component name:
TimeSeriesMap[f[#c]&, ts]//NormalUse multiple components as arguments:
TimeSeriesMap[f[#c, #b]&, ts]//NormalMap over a time series with multidimensional components:
ToTabular[<|"name" -> RandomWord[3], "integers" -> RandomInteger[10, {3, 2}], "reals" -> RandomReal[1, {3, 4}]|>, "Columns"]ts = TimeSeries[%]TimeSeriesMap[f, ts]//NormalMap over parts of the components:
TimeSeriesMap[f[#integers[[1]], #reals[[ ;; 2]]]&, ts]//TabularUse TimeSeriesMap to find the norm of each value of a vector-valued time series:
α = {{.2, .1}, {-.3, .2}};
β = {{.2, .5}, {-.2, .9}};
Σ = {{1, 0}, {0, .3}};
sample = RandomFunction[ARMAProcess[{α}, {β}, Σ], {1, 10 ^ 2}];norms = TimeSeriesMap[Norm, sample]ListPlot[norms, Filling -> 0]Data Containers (7)
v = RandomInteger[{-10, 10}, 10]TimeSeriesMap[f, v]Set extreme values to Missing for a list of time-value pairs:
data = {{"2005", 1}, {"2006", -1}, {"2007", 3}, {"2008", 6}, {"2009", -2}, {"2010", 4}, {"2011", 5}, {"2012", 9999}, {"2013", 4}, {"2014", 2}};clip = TimeSeriesMap[If[# > 10, Missing[], #]&, data]DateListPlot[clip, GridLines -> {True, False}]Double the values of a TimeSeries:
ts = TimeSeries[TimeEventSeries`TimestampData[Association["UniformlySpacedQ" -> True, "Count" -> 100,
"Endpoints" -> TabularColumn[Association["Data" -> {{0, 99}, {}, None},
"ElementType" -> "Integer64"]], "MinimumTimeIncrement" -> 1, "Caller ... 8, -5.864937981765857,
-6.27785271209235, -5.841962111797332}, {}, None}, "ElementType" -> "Real64"]],
Association["ResamplingMethod" -> {"Interpolation", InterpolationOrder -> 1},
"TimeWindow" -> Automatic, "MetaInformation" -> None]];TimeSeriesMap[2 * #&, ts]Equivalently, simple operations can be performed using time series arithmetic:
2 * tsListLinePlot[{ts, %}]Construct a TemporalData with two paths:
path1 = {{0, 12.1}, {1, 13.2}, {2, 15.0}};
path2 = {{.3, 12.3}, {1.1, 3.4}, {1.7, 4.5}};td = TemporalData[{path1, path2}]TimeSeriesMap acts independently over the paths:
TimeSeriesMap[f, td]//NormalTimeSeriesMap[Round, td]//NormalShift the paths in TemporalData:
td = TemporalData[Automatic, {{{0.8046670011447656, 0.6424816687160839, -0.3687580957637058,
0.4628481191016882, 0.6513760827865932, 0.19165543283623954, 0.30464311463325267,
-0.9822712429552825, -1.0167795954508363, -1.179808617121842, 0.7468 ... -15.95818965999289, -15.432785308593996, -16.456943797427243,
-17.39684387275391, -18.043191111487896, -17.87617876899845, -17.2137849514934,
-17.84832779928046}}, {{1, 100, 1}}, 3, {"Continuous", 3}, {"Discrete", 1}, 1, {}}, False, 10.];p1 = ListLinePlot[td, PlotStyle -> RGBColor[0.368417, 0.506779, 0.709798]]TimeSeriesMap[# + 20&, td]Use time series arithmetic notation:
td + 20Show[ListLinePlot[%, PlotStyle -> RGBColor[0.880722, 0.611041, 0.142051]], p1, PlotRange -> All]Represent the events in an EventSeries by alternating colored disks:
es = EventSeries[RandomChoice[{1, 5} -> {1, 0}, 50]]ListPlot[es, Filling -> Axis]rg[c_, e_] := If[e == 0, c, RGBColor[0, c[[3]], c[[2]]]]c = RGBColor[0, .5, 1];i = 0;
disks = TimeSeriesMap[{c = rg[c, #], Disk[{++i / 15, 0}]}&, es]Graphics[Normal[disks["Values"]]]Add a Quantity to a time series with quantities:
ts = TimeSeries[Quantity[{0, 16, 9, 3, 7, 2, 17, 10, 6, 12}, "Meters"]];res = Quantity[10, "Meters"] + tsres//NormalListLinePlot[{ts, res}, PlotLegends -> {"ts", "shifted ts"}, Filling -> Axis, AxesLabel -> Automatic]Component Keys as Function Arguments (3)
Take a time series with multiple components:
ts = TimeSeries[{"a" -> {11, 17, 13}, "b" -> {"cat", "dog", "fox"}, "c" -> {.1, .5, .9}}, {0}]Create a new time series with an anonymous (simple) component:
TimeSeriesMap[Function[f[#c]], ts]Create a new time series with a named component:
TimeSeriesMap["new" -> Function[f[#c]], ts]TimeSeriesMap[{"a", "b", "new" -> Function[f[#c]], "c"}, ts]Use #Timestamp to map over the timestamps of a time series:
ts = TimeSeries[{"a" -> {11, 17, 13}, "b" -> {"cat", "dog", "fox"}, "c" -> {.1, .5, .9}}, {Today}]TimeSeriesMap[fun[#Timestamp]&, ts]//NormalMap over a time series with an anonymous component:
ts = TimeSeries[{.34, .56, .19}, {0}]TimeSeriesMap[f, ts]Equivalently, use the implied key for value:
TimeSeriesMap[f[#Value]&, ts]% === %%Use both implied keys for time and value:
TimeSeriesMap[f[#Value] + g[#Timestamp]&, ts]Applications (9)
Basic Applications (2)
Use a time series of the geo polygons from the Roman Empire to compute the time series of areas:
ts = EntityValue[Entity["HistoricalCountry", "RomanEmpire"], Dated["Polygon", All]]Compute the area of the Roman Empire over time:
TimeSeriesMap[GeoArea, ts]DateListPlot[%, TargetUnits -> "RomanCommonLeugae" ^ 2]Compute the ratio of rail line lengths between Finland and Sweden:
[image]DateListPlot[data, PlotLegends -> Rest[ColumnKeys[data]]]TimeSeriesMap[#Finland / #Sweden&, data]DateListPlot[%, PlotLabel -> "Finland/Sweden"]Natural Phenomena (3)
Take a time series of solar x-ray flux density:
ts = TimeSeries[TimeEventSeries`TimestampData[Association["UniformlySpacedQ" -> True, "Count" -> 1153,
"Endpoints" -> TabularColumn[Association[
"Data" -> {2, {{{1748736000000, 1749081600000}, {}, None}}, None},
"ElementType" -> TypeSpe ... arInterpolation",
"LongFlux" -> "LinearInterpolation"], "TimeWindow" ->
DateInterval[{{{2025, 6, 1, 0, 0, 0.}, {2025, 6, 5, 0, 0, 0.}}}, "Instant", "Gregorian",
"-05:00"], "MetaInformation" -> Association["Name" -> "SolarXRayFlux"]]];The data contains two wavelength components:
ColumnKeys[ts]ListLogPlot[ts, Joined -> True]Compute the flux ratio of the two wave bands:
TimeSeriesMap[Function[#LongFlux / #ShortFlux], ts]ListLinePlot[%, PlotRange -> All]Time series of wind speeds in Champaign, IL, in May 2014:
data = WeatherData[{"Champaign", "Illinois"}, "WindSpeed", {2014, 5}]wd = TransformMissing[data, "Interpolation"]Use TimeSeriesMap to build the time series for the power output of a 1.5 MW wind turbine:
if = InterpolatingFunction[{{0., 30.}}, {5, 7, 0, {61}, {4}, 0, 0, 0, 0, Automatic, {}, {}, False},
{{0., 0.5, 1., 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5., 5.5, 6., 6.5, 7., 7.5, 8., 8.5, 9., 9.5, 10.,
10.5, 11., 11.5, 12., 12.5, 13., 13.5, 14., 14.5, ... 1477., 1494., 1500., 1500., 1500., 1500., 1500., 1500., 1500., 1500., 1500., 1500., 1500.,
1500., 1500., 1500., 1500., 1500., 1500., 1500., 1500., 1500., 1500., 1500., 1500., 1500., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0.}}, {Automatic}];
power[s_] := Quantity[if[QuantityMagnitude[s, "m/s"]], "Kilowatts"];output = TimeSeriesMap[power, wd]Visualize the daily moving average of the energy output:
ma = MovingMap[Mean, output, {Quantity[1, "Day"]}];DateListPlot[ma, PlotTheme -> {"Detailed", "ThinLines"}, FrameLabel -> Automatic, ImageSize -> 300, Filling -> Bottom]Compute the instants of March equinox for 800 consecutive years:
FindAstroEvent["MarchEquinox", DateRange[DateObject@{1800}, {2599}, "Year"]]Find their days in March as reals with fractional day decimal parts:
es = TimeSeriesMap[DateValue[#, "DayExact"]&, %]March equinoxes happen on days 19, 20 or 21:
MinMax[es]The fractional part represents time of the day:
TimeObject[24FractionalPart[First[%]]]Show how they drift year to year and how leap days must be handled differently in cycles of 400 years:
DateListPlot[es, Joined -> False, FrameTicks -> {{{{19, "Mar 19 00:00"}, {19.5, "Mar 19 12:00"}, {20, "Mar 20 00:00"}, {20.5, "Mar 20 12:00"}, {21, "Mar 21 00:00"}, {21.5, "Mar 21 12:00"}}, None}, {Automatic, None}}]Finance (1)
Visualize current maximum prices of stock over a given investment horizon:
prices = TemporalData[TimeSeries, {{{26.97, 26.65, 26.55, 27.52, 27.54, 27.41, 26.42, 26.34, 26.68, 28.53,
28.03, 27.9, 27.69, 28.1, 28.73, 28.39, 29.17, 30.08, 30.78, 31.28, 30.91, 30.8, 31.73, 32.,
31.56, 31.96, 33.04, 34.01, 33.56, 35.79, 36.21 ... 9.85, 39.93, 39.98}},
{TemporalData`DateSpecification[{2013, 1, 2, 0, 0, 0.}, {2013, 11, 27, 0, 0, 0}, {1, "Week"}]},
1, {"Continuous", 1}, {"Discrete", 1}, 1,
{ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, True, 10.1];
currentMaximumPrices = Block[{currMax = prices["FirstValue"]}, TimeSeriesMap[(currMax = Max[currMax, #])&, prices]]DateListPlot[{prices, currentMaximumPrices}, PlotLegends -> {"Prices", "CurrentMaximumPrices"}]Economics (2)
Find the number of unemployed in France using labor force and unemployement rate data:
data = Block[...]Tabular[data]Unemployment is the corresponding fraction of the labor force:
fun[g_] := Function[#[ExtendedKey["LaborForce", g]] * Normal[#[ExtendedKey["UnemploymentRate", g]]]]unemployment = TimeSeriesMap[{"FemaleUnemployed" -> fun["Female"], "MaleUnemployed" -> fun["Male"]}, data]DateListPlot[unemployment, PlotLegends -> {"Female", "Male"}]Compute the total unemployement:
total = TimeSeriesMap[Total, unemployment]DateListPlot[{unemployment, total}, PlotLegends -> LineLegend[...]]Take a time series of market share of web browsers:
ts = TimeSeries[TimeEventSeries`TimestampData[Association["UniformlySpacedQ" -> False,
"Timestamps" -> TabularColumn[Association[
"Data" -> {163, {{NumericArray[{14245, 14276, 14304, 14335, 14365, 14396, 14426, 14457,
14488, 14518, ... ",
"Other" -> "LinearInterpolation"], "TimeWindow" ->
DateInterval[{{{2009, 1, 1, 0, 0, 0.}, {2022, 7, 1, 0, 0, 0.}}}, "Day", "Gregorian", None, "UT",
Automatic], "MetaInformation" -> Association["Name" -> "WebBrowsersMarketShare"]]];Each component corresponds to a web browser:
ts["FirstValue"]//NormalTake the three most popular web browsers over time:
TimeSeriesMap[Keys@TakeLargest[#, 3]&, ts]Visualize the web browser dominance over time:
DateListPlot[%, ScalingFunctions -> NominalScale[Automatic], PlotLegends -> {"first", "second", "third"}]Random Processes (1)
Use TimeSeriesMap to calculate determinants of covariance matrices for an ARProcess:
cov = CovarianceFunction[ARProcess[{{{1 / 3, 1 / 2}, {-1 / 4, 1 / 2}}}, {{1, 1 / 3}, {1 / 3, 1}}], {10}];det = TimeSeriesMap[Det, cov]det["Values"]//Normal%//NProperties & Relations (5)
Lists are enumerated by integers starting at 0:
TimeSeriesMap[f[#Timestamp]&, {x, y, z}]//NormalSome operations can be obtained using listability:
ts = TimeSeries[{7, 9, 16}, {1}];TimeSeriesMap[# + c&, ts]["Path"]Obtain the same result using listability:
(ts + c)["Path"]For a simple time series argument, # in the mapped function represents values:
simpleTS = TimeSeries[{3.5, 6.7, 8.4}, {11}]TimeSeriesMap[f[#]&, simpleTS]//NormalConvert the simple time series to a new time series with the named component "a":
compTS = RenameColumns[simpleTS, "Value" -> "a"]Now # represents associations:
TimeSeriesMap[f[#]&, compTS]//NormalUse #a as an argument to access the values themselves:
TimeSeriesMap[f[#a]&, compTS]//NormalTake a multi-component time series and construct another one with two new components:
ts = TimeSeries[{"a" -> {11, 17, 13}, "b" -> {"cat", "giraffe", "fox"}, "c" -> {.1, .5, .9}}, {0}]cspec = {"s" -> Function[Sqrt[#a]], "e" -> Function[Entropy[#b]]};TimeSeriesMap[cspec, ts]This result can be also obtained by converting to Tabular, using ConstructColumns and converting back:
ConstructColumns[Tabular[ts], cspec]TimeSeries[%, {ts["Times"]}]TimeSeriesMap[f,ts] is equivalent to TimeSeriesMapThread[Function[f[#2]],ts]:
ts = TimeSeries[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5]}, {1}]res = TimeSeriesMap[f, ts]Normal[res]res === TimeSeriesMapThread[f[#2]&, ts]Possible Issues (2)
The key "Timestamp" cannot be used as a new component key:
ts = TimeSeries[{11, 17, 13}, {Today}]TimeSeriesMap["Timestamp" -> f, ts]
TimeSeriesMap["time" -> f, ts]For time series with named components, #Value is not recognized:
ts = TimeSeries[{3.5, 6.7, 8.4}, {11}, {"a"}]TimeSeriesMap[f[#Value]&, ts]Use # to access the whole association or #a for the value of component "a":
TimeSeriesMap[f[#]&, ts]//NormalTimeSeriesMap[f[#a]&, ts]//NormalNeat Examples (2)
Visualize market share of web browsers:
ts = TemporalData[TimeSeries,
{{{{1.37, 64.97, 26.85, 2.79, 3.07, 0.01, 0, 0, 0, 0.12, 0.03, 0.01, 0, 0.01, 0, 0, 0, 0, 0, 0.08,
0, 0, 0, 0, 0.15, 0, 0, 0, 0, 0, 0.27, 0.04, 0.02, 0, 0, 0.02, 0, 0, 0, 0.2},
{1.5, 63.98, 27.66, 2.83, 3.09, 0 ... "Samsung", "AOL", "SeaMonkey", "Openwave", "Whale Browser", "Phantom", "SonyEricsson",
"Pale Moon", "Obigo", "Jasmine", "Other"}, ResamplingMethod ->
{"Interpolation", InterpolationOrder -> 1}, ValueDimensions -> 40}}, True, 314.1];The time series contains the percentage of market share for each month:
ts["FirstValue"]ts["MetaInformation"]Extract top seven dominant browsers for each month:
best7ts = TimeSeriesMap[With[{pos = Reverse@TakeLargest[# -> "Index", 7]}, {#[[pos]], ts["MetaInformation"][[pos]]}]&, ts];Animate[BarChart[First[best7ts[t]], BarOrigin -> Left, PlotLabel -> DateObject[t, "Month"], PlotRange -> {0, 75}, AxesLabel -> "%", ChartLabels -> Placed[Last[best7ts[t]], After], ChartStyle -> "DarkRainbow"], {t, ts["Dates"]}, AnimationRate -> 3, AnimationRunning -> False, SaveDefinitions -> True]Create a phase plot of sunrise and sunset times through a year:
start = DateObject[{2025, 1, 1}, "Day"];
end = DateObject[{2025, 12, 31}, "Day"];
range = DateRange[start, end, "Day"];rises = Sunrise[Entity["City", {"London", "GreaterLondon", "UnitedKingdom"}], range, TimeZone -> Entity["City", {"London", "GreaterLondon", "UnitedKingdom"}]]sets = Sunset[Entity["City", {"London", "GreaterLondon", "UnitedKingdom"}], range, TimeZone -> Entity["City", {"London", "GreaterLondon", "UnitedKingdom"}]]rises["FirstValue"]Convert the events to a time in the 24-hour day:
riseHour = TimeSeriesMap[DateValue[#, "HourExact"]&, rises]setHour = TimeSeriesMap[DateValue[#, "HourExact"]&, sets]ListPlot[Transpose[{riseHour["Values"], setHour["Values"]}], AxesLabel -> {"sunrise", "sunset"}, PlotStyle -> PointSize[Small], ColorFunction -> "Rainbow"]Related Guides
Text
Wolfram Research (2014), TimeSeriesMap, Wolfram Language function, https://reference.wolfram.com/language/ref/TimeSeriesMap.html (updated 2026).
CMS
Wolfram Language. 2014. "TimeSeriesMap." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2026. https://reference.wolfram.com/language/ref/TimeSeriesMap.html.
APA
Wolfram Language. (2014). TimeSeriesMap. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TimeSeriesMap.html
BibTeX
@misc{reference.wolfram_2026_timeseriesmap, author="Wolfram Research", title="{TimeSeriesMap}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/TimeSeriesMap.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_timeseriesmap, organization={Wolfram Research}, title={TimeSeriesMap}, year={2026}, url={https://reference.wolfram.com/language/ref/TimeSeriesMap.html}, note=[Accessed: 13-June-2026]}