Modify existing TimeArray
s
rename
and rename!
The rename
method allows the column name(s) to be changed. The rename!
is used for in-place update.
julia> rename(cl, :Close′) |> first
1×1 TimeArray{Float64, 1, Date, Vector{Float64}} 2000-01-03 to 2000-01-03 ┌────────────┬────────┐ │ │ Close′ │ ├────────────┼────────┤ │ 2000-01-03 │ 111.94 │ └────────────┴────────┘
julia> rename(cl, [:Close′]) |> first
1×1 TimeArray{Float64, 1, Date, Vector{Float64}} 2000-01-03 to 2000-01-03 ┌────────────┬────────┐ │ │ Close′ │ ├────────────┼────────┤ │ 2000-01-03 │ 111.94 │ └────────────┴────────┘
julia> rename(ohlc, [:Open′, :High′, :Low′, :Close′]) |> first
1×4 TimeArray{Float64, 2, Date, Matrix{Float64}} 2000-01-03 to 2000-01-03 ┌────────────┬────────┬───────┬────────┬────────┐ │ │ Open′ │ High′ │ Low′ │ Close′ │ ├────────────┼────────┼───────┼────────┼────────┤ │ 2000-01-03 │ 104.88 │ 112.5 │ 101.69 │ 111.94 │ └────────────┴────────┴───────┴────────┴────────┘
julia> rename(ohlc, :Open => :Open′) |> first
1×4 TimeArray{Float64, 2, Date, Matrix{Float64}} 2000-01-03 to 2000-01-03 ┌────────────┬────────┬───────┬────────┬────────┐ │ │ Open′ │ High │ Low │ Close │ ├────────────┼────────┼───────┼────────┼────────┤ │ 2000-01-03 │ 104.88 │ 112.5 │ 101.69 │ 111.94 │ └────────────┴────────┴───────┴────────┴────────┘
julia> rename(ohlc, :Open => :Open′, :Close => :Close′) |> first
1×4 TimeArray{Float64, 2, Date, Matrix{Float64}} 2000-01-03 to 2000-01-03 ┌────────────┬────────┬───────┬────────┬────────┐ │ │ Open′ │ High │ Low │ Close′ │ ├────────────┼────────┼───────┼────────┼────────┤ │ 2000-01-03 │ 104.88 │ 112.5 │ 101.69 │ 111.94 │ └────────────┴────────┴───────┴────────┴────────┘
julia> rename(ohlc, Dict(:Open => :Open′, :Close => :Close′)...) |> first
1×4 TimeArray{Float64, 2, Date, Matrix{Float64}} 2000-01-03 to 2000-01-03 ┌────────────┬────────┬───────┬────────┬────────┐ │ │ Open′ │ High │ Low │ Close′ │ ├────────────┼────────┼───────┼────────┼────────┤ │ 2000-01-03 │ 104.88 │ 112.5 │ 101.69 │ 111.94 │ └────────────┴────────┴───────┴────────┴────────┘
julia> rename(Symbol ∘ uppercase ∘ string, ohlc) |> first
1×4 TimeArray{Float64, 2, Date, Matrix{Float64}} 2000-01-03 to 2000-01-03 ┌────────────┬────────┬───────┬────────┬────────┐ │ │ OPEN │ HIGH │ LOW │ CLOSE │ ├────────────┼────────┼───────┼────────┼────────┤ │ 2000-01-03 │ 104.88 │ 112.5 │ 101.69 │ 111.94 │ └────────────┴────────┴───────┴────────┴────────┘
julia> rename(uppercase, ohlc, String) |> first
1×4 TimeArray{Float64, 2, Date, Matrix{Float64}} 2000-01-03 to 2000-01-03 ┌────────────┬────────┬───────┬────────┬────────┐ │ │ OPEN │ HIGH │ LOW │ CLOSE │ ├────────────┼────────┼───────┼────────┼────────┤ │ 2000-01-03 │ 104.88 │ 112.5 │ 101.69 │ 111.94 │ └────────────┴────────┴───────┴────────┴────────┘
TimeSeries.rename
— Functionrename(ta::TimeArray, colnames::Vector{Symbol})
rename(ta::TimeArray, colname::Symbol)
rename(ta::TimeArray, orig => new, ...)
rename(f::Base.Callable, ta, colnametyp)
Rename the columns of a TimeArray
.
See also rename!
.
Arguments
colnametyp
is the input type for the functionf
. The valid value isSymbol
orString
.
TimeSeries.rename!
— Functionrename!(ta::TimeArray, colnames::Vector{Symbol})
rename!(ta::TimeArray, colname::Symbol)
rename!(ta::TimeArray, orig => new, ...)
rename!(f::Base.Callable, ta, colnametyp)
In-place rename the columns of a TimeArray
.
See also rename
.
Arguments
colnametyp
is the input type for the functionf
. The valid value isSymbol
orString
.