嵌套字典包含以下数据:{names,{dates,prices}}
结构如此:
type Dict<'T, 'U> = System.Collections.Generic.Dictionary<'T, 'U>
let masterDict = Dict<string, Dict<Datetime, float>> ()
原始数据如下:
> masterDict.Keys |> printfn "%A"
seq ["Corn Future"; "Wheat Future"]
> masterDict.["Corn Future"] |> printfn "%A"
seq [[2009-09-01, 316.69]; [2009-09-02, 316.09]; [2009-09-03, 316.33]; ...]
> masterDict.["Wheat Future"] |> printfn "%A"
seq [[2009-09-01, 214.4]; [2009-09-02, 223.86]; [2009-09-03,
234.11]; [2009-09-04, 224.62]; ...]
我尝试将上面的数据全部加入到Deedle框架中,如下所示:
Corn Future Wheat Future
2009-09-01 316.69 214.4
2009-09-02 316.09 223.86
2009-09-03 316.33 234.11
2009-09-04 NaN 224.62 // in case a point is not available
Deedle的机制对我来说仍然是陌生的。任何帮助将不胜感激。
答案 0 :(得分:3)
Deedle库中有一些扩展方法(主要是为了使它对C#友好),它与<link href="https://maxcdn.bootstrapcdn.com/bootswatch/latest/journal/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-xs-9">
1
</div>
<div class="col-xs-3">
2
</div>
</div>
<div class="row push-to-bottom">
<div class="col-xs-9 text-center">
<button>
Bottom
</button>
</div>
</div>
</div>
一起使用而不是元组(这是F#的默认值)。
所以你应该能够简化Foggy Finder发布的答案(假设你在顶部有KeyValuePair
):
open Deedle
答案 1 :(得分:1)
不确定你要加入什么,但你可以改变:
let frame =
masterDict
|> Seq.map(fun kv -> kv.Key, kv.Value
|> Seq.map(fun nkv -> nkv.Key, nkv.Value)
|> Series.ofObservations)
|> Frame.ofColumns
frame.Format() |> printfn "%s"
然后你得到了:
Corn Future Wheat Future
01.09.2009 0:00:00 -> 316,69 214,4
02.09.2009 0:00:00 -> 316,09 223,86
03.09.2009 0:00:00 -> 316,33 234,11
04.09.2009 0:00:00 -> <missing> 224,62