deedle - Filtering Rows in F# -
i have code have following frame , filter rows follows:
let dfff= [ "year" => series [ 1 => 1990.0; 2 => 1991.00; 3 => 1992.0; 4 => 1993.0] "gold" => series [ 1 => 10.0; 2 => 10.00; 3 => 15.0; 4 => 20.0] "silver" => series [ 1 => 20.0; 2 => 30.00; 3 => 45.0; 4 => 55.0] ] |> frame let dfff2 = dfff |> frame.filterrows (fun key row -> row?year <= 1992.0 )
why have write key in
frame.filterrows (fun key row -> row?year <= 1992.0)
if function depends on row? role key play here? appreciate if explain me logic. thanks!
in deedle, frames have row keys , column keys. in case, have frame<int, string>
meaning row keys integers (just numbers) , column keys strings (column names) - might have dates or other more interesting things row keys.
the filterrows
function gives row key row data. key
parameter row key - in case, (uninteresting) int index, might e.g. useful date in other scenarios.
f# lets write _
explicitly ignore value:
let dfff2 = dfff |> frame.filterrows (fun _ row -> row?year <= 1992.0 )
in series
module, have series.filter
, series.filtervalues
first 1 gives key & value , second 1 gives value. so, follow same pattern , add frame.filterrowvalues
.
this quite easy, if want contribute, please send pull request change somewhere around here :-).
Comments
Post a Comment