By position I mean:
let position:int = positionForKey frame key
let row =
Frame.take positionForKey
|> frame.takeLast 1
Then, row
should be a Frame with only one row, whose key is key
.
What I don't know is how to achieve positionForKey
. One idea that should work but I don't know if it's the best way of doing it would be to create another Series
via Series.scanValues
and let the values be the positions, but I think there oughts to be a more elegant way of doing it.
The implementation via Series.scanValues
would be:
let positionForKey (frame:Frame<'K,_>) (key:'K) =
let positions = Series.scanValues (fun pos _ -> pos + 1) 0 (frame.GetColumnAt 0)
positions.[key]
... index beginning from 1
Example
Say you have a Frame f
like this:
03/01/01, 4 , ...
04/01/01, 3 , ...
05/01/01, 6 , ...
... , ..., ...
then, positionforKey f 04/01/01 = 2
, positionforKey f 05/01/01 = 3
and so on. (Supposing that 04/01/01 was a valid DateTime)