为什么 Frame.tryValues 在这个简单的例子中会失败?
Why does Frame.tryValues fail in this simple example?
Frame.tryValues
的帮助内容如下:
"Given a data frame containing columns of type tryval<'T>
, returns a new data frame that contains the underlying values of type 'T
."
我将其解释为该函数将从值中剥离类型 tryval
,并从这些剥离的值中剥离 return。可能我没看懂文中的内容,因为在以下情况下函数失败:
let dates =
[ DateTime(2013,1,1);
DateTime(2013,1,2);
DateTime(2013,1,3) ]
let values = [ 10.0; 20.0; 30.0 ]
let first = Series(dates, values)
let frame = Frame(["first"], [first])
let f (dt: DateTime) (row: ObjectSeries<string>) = row.Get("first") :?> double
let s =
frame
|> Frame.tryMapRows f
// frame1's second column has tryvalues
let frame1 = Frame(["first"; "second"], [first; s])
// frame2 has no tryvalues
let frame2 = Frame(["first"; "second"], [first; first])
let frame3 =
frame1
|> Frame.tryValues
// fails
let frame3 =
frame2
|> Frame.tryValues
// Ok, works fine
为什么第一次调用上面的 Frame.tryValues
失败但第二次没有?
事实证明这是 Deedle 中的一个错误。我调查了一下 submitted a PR with a fix.
Frame.tryValues
的帮助内容如下:
"Given a data frame containing columns of type tryval<'T>
, returns a new data frame that contains the underlying values of type 'T
."
我将其解释为该函数将从值中剥离类型 tryval
,并从这些剥离的值中剥离 return。可能我没看懂文中的内容,因为在以下情况下函数失败:
let dates =
[ DateTime(2013,1,1);
DateTime(2013,1,2);
DateTime(2013,1,3) ]
let values = [ 10.0; 20.0; 30.0 ]
let first = Series(dates, values)
let frame = Frame(["first"], [first])
let f (dt: DateTime) (row: ObjectSeries<string>) = row.Get("first") :?> double
let s =
frame
|> Frame.tryMapRows f
// frame1's second column has tryvalues
let frame1 = Frame(["first"; "second"], [first; s])
// frame2 has no tryvalues
let frame2 = Frame(["first"; "second"], [first; first])
let frame3 =
frame1
|> Frame.tryValues
// fails
let frame3 =
frame2
|> Frame.tryValues
// Ok, works fine
为什么第一次调用上面的 Frame.tryValues
失败但第二次没有?
事实证明这是 Deedle 中的一个错误。我调查了一下 submitted a PR with a fix.