【问题标题】:F# Deedle Filtering a data frame using String.ContainsF# Deedle 使用 String.Contains 过滤数据框
【发布时间】:2014-05-08 03:00:02
【问题描述】:

我有一个看起来像这样的数据框

          Date                        Type   last  LastSize       
12    -> 2013-10-25T00:00:00.575556Z  trade 273  20     
13    -> 2013-10-25T00:00:00.575556Z  quote 0    0       
:         ...                         ...    ...   ...      
26554 -> 2013-10-25T06:04:59.741493Z  trade 273  2       
26555 -> 2013-10-25T06:04:59.751844Z  trade 273  8  

我想根据标记为Type 的字段进行过滤。具体来说,我想过滤数据框以仅包含列Type 包含 字符串“trade”的行。

let tradesOnly = lastFrame.GetSeries<string>("Type")
                |> Series.filterValues (fun t -> t.Contains "trade")

这将正确过滤,但仅在我使用 GetSeries 时为我提供系列。 Deedle 样本包括有一个类似这样的 sn-p

let x = lastFrame.RowsDense 
        |> Series.filterValues (fun row -> row.GetAs<string>("Type") = "trade")
        |> Series.countValues

这会编译但返回一个空数据框,因为我需要 contains 而不是 equals。如何按字符串过滤帧包含? `

【问题讨论】:

    标签: string f# contains deedle


    【解决方案1】:

    row.GetAs&lt;string&gt;("Type").Contains("trade") 应该这样做。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-30
      • 1970-01-01
      相关资源
      最近更新 更多