0
嗨,我是使用下面的代码:Deedle系列指数超出范围
let timeser = ser |> Series.sampleTimeInto(TimeSpan(0,5,0)) Direction.Backward Series.lastValue
但是经常会出现以下错误;带附加信息的System.IndexOutOfRangeException:索引超出了数组的范围。
有谁知道如何解决这个错误。
嗨,我是使用下面的代码:Deedle系列指数超出范围
let timeser = ser |> Series.sampleTimeInto(TimeSpan(0,5,0)) Direction.Backward Series.lastValue
但是经常会出现以下错误;带附加信息的System.IndexOutOfRangeException:索引超出了数组的范围。
有谁知道如何解决这个错误。
由于我们无法运行您的代码,因此有点难以猜出问题所在。但例外的最明显原因是Series.lastValue
失败,因为其中一个块没有数据。
比方说,你有值的系列仅2日:
let ser = series [ DateTime(2000, 1, 1) => 1.0; DateTime(2000, 1, 2) => 2.0 ]
如果你尝试将其品尝到用Series.lastValue
12小时块,那么这个失败(因为只有两个区块的你实际上包含一些值):
// This shows you that some of the chunks are empty
ser |> Series.sampleTime (TimeSpan(12,0,0)) Direction.Backward
// This will fail
ser |> Series.sampleTimeInto(TimeSpan(12,0,0)) Direction.Backward Series.lastValue
您可以以不同的方式处理这个问题,但最简单的一个将是没有数据返回块缺失值:
ser |> Series.sampleTimeInto(TimeSpan(12,0,0)) Direction.Backward (fun s ->
if s.IsEmpty then nan else Series.lastValue s)
建议:发布一些数据以使此问题可重现 – 2015-03-03 21:02:42