您应该能够对原始系列执行外连接(最好将它们变成框架,因为这样您会得到很好的多列框架),然后填充缺失值Frame.fillMissing
。
// Note that s1[2] is undefined and s2[3] is undefined
let s1 = series [ 1=>1.0; 3=>3.0; 5=>5.0 ]
let s2 = series [ 1=>1.1; 2=>2.2; 5=>5.5 ]
// Build frames to make joining easier
let f1, f2 = frame [ "S1" => s1 ], frame [ "S2" => s2 ]
// Perform outer join and then fill the missing data
let f = f1.Join(f2, JoinKind.Outer)
let res = f |> Frame.fillMissing Direction.Forward
最终结果和缺失值的中间帧如下所示:
val it : Frame<int,string> =
S1 S2
1 -> 1 1.1
2 -> <missing> 2.2
3 -> 3 <missing>
5 -> 5 5.5
>
val it : Frame<int,string> =
S1 S2
1 -> 1 1.1
2 -> 1 2.2
3 -> 3 2.2
5 -> 5 5.5
请注意,结果仍可能包含缺失值 - 如果第一个值缺失,则该fillMissing
函数没有要传播的先前值,因此该系列可能以一些缺失值开始。