Skip to main content
added 83 characters in body
Source Link
Mike Honeychurch
  • 37.8k
  • 3
  • 87
  • 161

To me this looks like an ambiguity in the docs when "Month" is specified as a possible shift because everything else implies a fixed shifting increment. If you really want to shift your data by a calendar month then try this:

monthShift[timeSeries_, months_] := 
 Module[{ts = timeSeries}, 
  ts[[2, 2, 1, 1]] = (DatePlus[#1, {months, "Month"}] &) /@ 
    ts[[2, 2, 1, 1]]; ts]

enter image description here

Edit

Just to explain the use of Part, while TimeSeries returns a panelled object, with appearance controlled by the option:

SetSystemOptions["TypesetOptions" -> "IconicElidedForms" -> True/False]

the underlying stored data and other information can be obtained by reverting to InputForm (or programmatically by applying FullForm) which gives:

TemporalData[TimeSeries, {{{0.7949834094555914, 0.4347500722147044, 
     0.10713327154725061, 0.25342805865761253, 0.7948229764103827, 0.2102978027596214, 
     0.42632147952029165, 0.2416091155261224, 0.4974007836596186, 0.5213253136688505, 
     0.8890068839125953, 0.45179928777848866, 0.31725637968735665}}, 
   {{{3537043200, 3539548800, 3542227200, 3544819200, 3547497600, 3550089600, 
      3552768000, 3555446400, 3558038400, 3560716800, 3563308800, 3565987200, 
      3568665600}}}, 1, {Continuous, 1}, {Discrete, 1}, 1, 
   {ValueDimensions -> 1, ResamplingMethod -> {Interpolation, 
      InterpolationOrder -> 1}}}, True, 10.]

From the above we can see that the dates (in absolute time) are part 2,2,1,1.

enter image description here

To me this looks like an ambiguity in the docs when "Month" is specified as a possible shift because everything else implies a fixed shifting increment. If you really want to shift your data by a calendar month then try this:

monthShift[timeSeries_, months_] := 
 Module[{ts = timeSeries}, 
  ts[[2, 2, 1, 1]] = (DatePlus[#1, {months, "Month"}] &) /@ 
    ts[[2, 2, 1, 1]]; ts]

enter image description here

Edit

Just to explain the use of Part, while TimeSeries returns a panelled object, with appearance controlled by the option:

SetSystemOptions["TypesetOptions" -> "IconicElidedForms" -> True/False]

the underlying stored data and other information can be obtained by reverting to InputForm (or programmatically by applying FullForm) which gives:

TemporalData[TimeSeries, {{{0.7949834094555914, 0.4347500722147044, 
     0.10713327154725061, 0.25342805865761253, 0.7948229764103827, 0.2102978027596214, 
     0.42632147952029165, 0.2416091155261224, 0.4974007836596186, 0.5213253136688505, 
     0.8890068839125953, 0.45179928777848866, 0.31725637968735665}}, 
   {{{3537043200, 3539548800, 3542227200, 3544819200, 3547497600, 3550089600, 
      3552768000, 3555446400, 3558038400, 3560716800, 3563308800, 3565987200, 
      3568665600}}}, 1, {Continuous, 1}, {Discrete, 1}, 1, 
   {ValueDimensions -> 1, ResamplingMethod -> {Interpolation, 
      InterpolationOrder -> 1}}}, True, 10.]

From the above we can see that the dates (in absolute time) are part 2,2,1,1.

To me this looks like an ambiguity in the docs when "Month" is specified as a possible shift because everything else implies a fixed shifting increment. If you really want to shift your data by a calendar month then try this:

monthShift[timeSeries_, months_] := 
 Module[{ts = timeSeries}, 
  ts[[2, 2, 1, 1]] = (DatePlus[#1, {months, "Month"}] &) /@ 
    ts[[2, 2, 1, 1]]; ts]

enter image description here

Edit

Just to explain the use of Part, while TimeSeries returns a panelled object, with appearance controlled by the option:

SetSystemOptions["TypesetOptions" -> "IconicElidedForms" -> True/False]

the underlying stored data and other information can be obtained by reverting to InputForm (or programmatically by applying FullForm) which gives:

TemporalData[TimeSeries, {{{0.7949834094555914, 0.4347500722147044, 
     0.10713327154725061, 0.25342805865761253, 0.7948229764103827, 0.2102978027596214, 
     0.42632147952029165, 0.2416091155261224, 0.4974007836596186, 0.5213253136688505, 
     0.8890068839125953, 0.45179928777848866, 0.31725637968735665}}, 
   {{{3537043200, 3539548800, 3542227200, 3544819200, 3547497600, 3550089600, 
      3552768000, 3555446400, 3558038400, 3560716800, 3563308800, 3565987200, 
      3568665600}}}, 1, {Continuous, 1}, {Discrete, 1}, 1, 
   {ValueDimensions -> 1, ResamplingMethod -> {Interpolation, 
      InterpolationOrder -> 1}}}, True, 10.]

From the above we can see that the dates (in absolute time) are part 2,2,1,1.

enter image description here

added 1149 characters in body
Source Link
Mike Honeychurch
  • 37.8k
  • 3
  • 87
  • 161

To me this looks like an ambiguity in the docs when "Month" is specified as a possible shift because everything else implies a fixed shifting increment. If you really want to shift your data by a calendar month then try this:

monthShift[timeSeries_, months_] := 
 Module[{ts = timeSeries}, 
  ts[[2, 2, 1, 1]] = (DatePlus[#1, {months, "Month"}] &) /@ 
    ts[[2, 2, 1, 1]]; ts]

enter image description here

Edit

Just to explain the use of Part, while TimeSeries returns a panelled object, with appearance controlled by the option:

SetSystemOptions["TypesetOptions" -> "IconicElidedForms" -> True/False]

the underlying stored data and other information can be obtained by reverting to InputForm (or programmatically by applying FullForm) which gives:

TemporalData[TimeSeries, {{{0.7949834094555914, 0.4347500722147044, 
     0.10713327154725061, 0.25342805865761253, 0.7948229764103827, 0.2102978027596214, 
     0.42632147952029165, 0.2416091155261224, 0.4974007836596186, 0.5213253136688505, 
     0.8890068839125953, 0.45179928777848866, 0.31725637968735665}}, 
   {{{3537043200, 3539548800, 3542227200, 3544819200, 3547497600, 3550089600, 
      3552768000, 3555446400, 3558038400, 3560716800, 3563308800, 3565987200, 
      3568665600}}}, 1, {Continuous, 1}, {Discrete, 1}, 1, 
   {ValueDimensions -> 1, ResamplingMethod -> {Interpolation, 
      InterpolationOrder -> 1}}}, True, 10.]

From the above we can see that the dates (in absolute time) are part 2,2,1,1.

To me this looks like an ambiguity in the docs when "Month" is specified as a possible shift because everything else implies a fixed shifting increment. If you really want to shift your data by a calendar month then try this:

monthShift[timeSeries_, months_] := 
 Module[{ts = timeSeries}, 
  ts[[2, 2, 1, 1]] = (DatePlus[#1, {months, "Month"}] &) /@ 
    ts[[2, 2, 1, 1]]; ts]

enter image description here

To me this looks like an ambiguity in the docs when "Month" is specified as a possible shift because everything else implies a fixed shifting increment. If you really want to shift your data by a calendar month then try this:

monthShift[timeSeries_, months_] := 
 Module[{ts = timeSeries}, 
  ts[[2, 2, 1, 1]] = (DatePlus[#1, {months, "Month"}] &) /@ 
    ts[[2, 2, 1, 1]]; ts]

enter image description here

Edit

Just to explain the use of Part, while TimeSeries returns a panelled object, with appearance controlled by the option:

SetSystemOptions["TypesetOptions" -> "IconicElidedForms" -> True/False]

the underlying stored data and other information can be obtained by reverting to InputForm (or programmatically by applying FullForm) which gives:

TemporalData[TimeSeries, {{{0.7949834094555914, 0.4347500722147044, 
     0.10713327154725061, 0.25342805865761253, 0.7948229764103827, 0.2102978027596214, 
     0.42632147952029165, 0.2416091155261224, 0.4974007836596186, 0.5213253136688505, 
     0.8890068839125953, 0.45179928777848866, 0.31725637968735665}}, 
   {{{3537043200, 3539548800, 3542227200, 3544819200, 3547497600, 3550089600, 
      3552768000, 3555446400, 3558038400, 3560716800, 3563308800, 3565987200, 
      3568665600}}}, 1, {Continuous, 1}, {Discrete, 1}, 1, 
   {ValueDimensions -> 1, ResamplingMethod -> {Interpolation, 
      InterpolationOrder -> 1}}}, True, 10.]

From the above we can see that the dates (in absolute time) are part 2,2,1,1.

Source Link
Mike Honeychurch
  • 37.8k
  • 3
  • 87
  • 161

To me this looks like an ambiguity in the docs when "Month" is specified as a possible shift because everything else implies a fixed shifting increment. If you really want to shift your data by a calendar month then try this:

monthShift[timeSeries_, months_] := 
 Module[{ts = timeSeries}, 
  ts[[2, 2, 1, 1]] = (DatePlus[#1, {months, "Month"}] &) /@ 
    ts[[2, 2, 1, 1]]; ts]

enter image description here