Datetime 从两个框架列计算时间跨度

Datetime 从两个框架列计算时间跨度,datetime,f#,deedle,Datetime,F#,Deedle,我有一个deedle框架,其中有两列包含日期时间戳。 我想计算两者之间的差异(timaspan) type Test = { id : int; start : DateTime; finish : DateTime } let testData = [ {id = 1; start = DateTime.Parse("13.01.2014 00:45:38"); finish = DateTime.Parse("13.01.2014 03:15:39"

我有一个deedle框架,其中有两列包含日期时间戳。 我想计算两者之间的差异(timaspan)

type Test = { 
    id : int;
    start : DateTime;
    finish : DateTime    }

let testData = [
    {id = 1; start = DateTime.Parse("13.01.2014 00:45:38"); finish = DateTime.Parse("13.01.2014 03:15:39")};
    {id = 2; start = DateTime.Parse("15.01.2014 00:30:38"); finish = DateTime.Parse("16.01.2014 01:07:39")}]

let testFrame = Frame.ofRecords testData

testFrame?TimeSpan <- testFrame |> Frame.mapRowValues (fun row -> 
    row?finish - row?start )
类型测试={
id:int;
开始:日期时间;
完成:日期时间}
设testData=[
{id=1;start=DateTime.Parse(“13.01.2014 00:45:38”);finish=DateTime.Parse(“13.01.2014 03:15:39”);
{id=2;start=DateTime.Parse(“15.01.2014 00:30:38”);finish=DateTime.Parse(“16.01.2014 01:07:39”)}]
让testFrame=Frame.of记录测试数据
testFrame?TimeSpan Frame.mapRowValues(有趣的行->
行?完成-行?开始)

行?finish
中使用
操作符是
行的快捷方式。GetAs(“finish”)
意味着它访问一列并尝试将其转换为
float
——操作符之所以这样做,是因为这似乎是最常见的情况,因此我们想让它变得简单

如果需要使用其他类型,则需要明确使用
GetAs

testFrame?TimeSpan <- testFrame |> Frame.mapRowValues (fun row -> 
    row.GetAs<DateTime>("finish") - row.GetAs<DateTime>("start") )
testFrame?TimeSpan Frame.mapRowValues(有趣的行->
row.GetAs(“完成”)-row.GetAs(“开始”))
还请检查此项,其中讨论了使用
DateTime
DateTimeOffset
之间的区别,以确保使用正确的类型表示时间