参考文档 链接: A Julia equivalent to Pandas date_range function
function timestamps(start::TimeType, freq::DataType, obs::Int, step::Int=1)
steps = freq(step)
periods = obs * step
finish = start + freq(periods - 1)
collect(start:steps:finish)
end
# start = Date(2000,1,30)
# freq = Day
# lenth = 100
# step = 1 默认的
timestamps(Date(2000,1,30), Day, 100)
100-element Array{Date,1}:
2000-01-30
2000-01-31
2000-02-01
2000-02-02
2000-02-03
2000-02-04
2000-02-05
2000-02-06
2000-02-07
2000-02-08
2000-02-09
2000-02-10
2000-02-11
⋮
2000-04-27
2000-04-28
2000-04-29
2000-04-30
2000-05-01
2000-05-02
2000-05-03
2000-05-04
2000-05-05
2000-05-06
2000-05-07
2000-05-08
# start = Date(2000,1,30)
# freq = Day
# lenth = 100
# step = 2
timestamps(Date(2000,1,30), Day, 100, 2)
100-element Array{Date,1}:
2000-01-30
2000-02-01
2000-02-03
2000-02-05
2000-02-07
2000-02-09
2000-02-11
2000-02-13
2000-02-15
2000-02-17
2000-02-19
2000-02-21
2000-02-23
⋮
2000-07-24
2000-07-26
2000-07-28
2000-07-30
2000-08-01
2000-08-03
2000-08-05
2000-08-07
2000-08-09
2000-08-11
2000-08-13
2000-08-15
网友评论