这是一个小例子,我想处理系列上自定义函数的缺失值。
假设我已经获得了一系列
series4;;
val it : Series<int,int opt> =
1 -> 1
2 -> 2
3 -> 3
4 -> <missing>
例如,这样:
let series1 = Series.ofObservations [(1,1);(2,2);(3,3)]
let series2 = Series.ofObservations [(1,2);(2,2);(3,1);(4,4)]
let series3 = series1.Zip(series2,JoinKind.Outer);;
let series4 = series3 |> Series.mapValues fst
那么如果我这样做的话
Series.mapAll (fun v -> match v with
| Some a -> (a>1)
| _-> false) series4
失败了
System.Exception:由于较早的原因,操作无法完成
错误“int option”类型与“int opt”类型不匹配。看
还输入.fsx(4,42)-(4,49)。 4,42 时
虽然我希望结果是
val it : Series<int,bool opt> =
1 -> false
2 -> true
3 -> true
4 -> false
更好的是能够得到像这样的结果
val it : Series<int,int opt> =
1 -> false
2 -> true
3 -> true
4 -> <missing>
那里正确的语法是什么?理想情况下,如果有一个<missing>
值,我想要一个<missing>
新系列中相同键的值
基本上我需要进行模式匹配int opt
type
额外问题:Deedle 中是否有针对一些常用运算符(例如“>”)的矢量化运算符?
(series1 > series2) 当两个系列具有相同的键类型时将返回一个新的布尔值系列(选项?)类型
thanks