0

自 Deedle 1.0.7 发布以来,索引行功能不再验证被用作键的列是否包含唯一值。这种行为与评论所暗示的不同。如何确保只有唯一值可以用作列键?

在以前的版本中,以下代码将触发错误,因为用作索引的列包含重复项。但是在 Deedle 1.0.7 中不再是这种情况,代码将起作用,并且框架将包含 1 个指向记录数组的索引条目。这是设计使然吗?

type t1 = {d:DateTime; v:double}

let s1 =[{d=DateTime.Now.Date; v= 1.0};
          {d=DateTime.Now.Date; v= 2.0};
          {d=DateTime.Now.Date; v= 3.0};
         ]

let f1 = Frame.ofRecords s1 |> Frame.indexRowsDate "d"


 type t2 = {d:int; v:double}

 let s2 =[{d=1; v= 1.0};
          {d=1; v= 2.0};
           {d=1; v= 3.0};
         ]

 let f2 = Frame.ofRecords s2 |> Frame.indexRowsInt "d"

但是,如果我尝试访问由重复键 Deedle 索引的系列会出错

let cv = f2.GetColumn<double> "v"

let item = cv.Get(1)

val cv : Series<int,double> = series [ 1 => 1; 1 => 2; 1 => 3]

> 
System.ArgumentException: Duplicate key '1'. Duplicate keys are not     allowed in the index.
 Parameter name: keys
   at Deedle.Indices.Linear.LinearIndex`1.makeLookup() in     c:\Tomas\Public\Deedle\src\Deedle\Indices\LinearIndex.fs:line 53

在 Deedle.Indices.Linear.LinearIndex 1.get_lookupMap() in c:\Tomas\Public\Deedle\src\Deedle\Indices\LinearIndex.fs:line 63 at Deedle.Indices.Linear.LinearIndex1.Deedle-Indices-IIndex 2.Get 1-Locate(K key) in c:\Tomas\Public\Deedle\src\Deedle\Indices\LinearIndex.fs:line 101 at Deedle.Series(K key) in c:\Tomas\Public\Deedle\src\Deedle\Series.fs:line 291 at .$FSI_0046.main@( ) 在 C:\Users\win8dev\Documents\Visual Studio 2013\Projects\DeedleTake2\Deedle107\Script.fsx:line 40 由于错误而停止

更新:

正如 Tomas 所建议的那样,已提出 Github 票证

https://github.com/BlueMountainCapital/Deedle/issues/294

4

0 回答 0