Modify existing TimeArrays

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′) |> first1×1 TimeArray{Float64, 1, Date, Vector{Float64}} 2000-01-03 to 2000-01-03
┌────────────┬────────┐
│            │ Close′ │
├────────────┼────────┤
│ 2000-01-03 │ 111.94 │
└────────────┴────────┘
julia> rename(cl, [:Close′]) |> first1×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′]) |> first1×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′) |> first1×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′) |> first1×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′)...) |> first1×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) |> first1×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) |> first1×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.renameFunction
rename(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 function f. The valid value is Symbol or String.
source
TimeSeries.rename!Function
rename!(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 function f. The valid value is Symbol or String.
source