Closed scls19fr closed 5 years ago
Here is a possible implementation:
using Dates
using Test
using TimeSeries
import TimeSeries.TimeArray
data = (time=[DateTime(2018, 11, 21, 12, 0), DateTime(2018, 11, 21, 13, 0)], col1=[10.2, 11.2], col2=[20.2, 21.2], col3=[30.2, 31.2])
function TimeArray(data::NamedTuple; timestamp=:time)
columns = (key for key in keys(data) if key != timestamp)
dat = hcat((data[key] for key in columns)...)
TimeArray(data[timestamp], dat, collect(columns))
end
ta = TimeArray(data)
println(ta)
@test size(ta) == (2, 3)
An other (related) feature would be to support DataStreams ie be able to support Data.stream!(result, TimeArray)
and fetch!(TimeArray, result)
like mentioned in https://invenia.github.io/LibPQ.jl/latest/index.html
Could you send the code as a PR?
Hello,
DataFrame from DataFrames.jl can be construct from
NamedTuple
It will be nice if
TimeArray
could also be constructed like this.maybe passing name of datetime column should be considered (as a
Symbol
).LibPQ uses this kind of mechanism https://invenia.github.io/LibPQ.jl/latest/index.html
Kind regards
PS : similar to https://github.com/dysonance/Temporal.jl/issues/33