JuliaStats / TimeSeries.jl

Time series toolkit for Julia
Other
352 stars 69 forks source link

Modify TimeArray object by providing an index or index range #441

Closed kunov closed 4 years ago

kunov commented 4 years ago
> t_a

8×1 TimeArray{Float64,1,Date,Array{Float64,1}} 2000-01-01 to 2001-10-01
│            │ A      │
├────────────┼────────┤
│ 2000-01-01 │ 1.0    │
│ 2000-04-01 │ 0.4491 │
│ 2000-07-01 │ 0.411  │
│ 2000-10-01 │ 0.2741 │
│ 2001-01-01 │ 0.2303 │
│ 2001-04-01 │ 0.241  │
│ 2001-07-01 │ 0.9306 │
│ 2001-10-01 │ 0.8056 │

I want to be able to do the following:

rng = Date(2001, 1):Month(3):Date(2001, 4)

t_a[rng] = [1 2]

Is there a way modify an existime TimeArray object?

The only way I found to change the value at index is to go:

values(timeArray object)[1] = 100

ValentinKaisermayer commented 4 years ago

Since a TimeArray is immutable there is no possibility to do this. https://github.com/JuliaStats/TimeSeries.jl/blob/c730d62e22156f5f2ec1cf4af7c4dba84114e876/src/timearray.jl#L52