What is the proper way to change one observation in a TimeSeries object?
Let's say there a time series:
ts = TimeSeries[Transpose[{Range[10], RandomReal[{0, 1}, 10]}]]
Now, I need to alter the 2nd observation to some value like 3.
ts[2] = 3
(*produces error: TemporalData is Protected *)
Now, I can define something like this:
TimeSeriesAssign[ts_, v_] := TimeSeries[
ts["DatePath"] /. {DateObject[First@v], _} :> {DateObject@First@v,
Last@v}]
...which does the job:
ts = TimeSeriesAssign[ts, {2, 3}]
ts[2]
(*3*)
But is there a better, preferably built-in way to make assignments to TimeSeries object's observations?