Search code examples
f#deedle

Deedle series.ValuesAll raise Error: OptionalValue.Value: Value is not available


The ValuesAll function of the Deedle series according to the doco is to

Returns a collection of values, including possibly missing values. Note that the length of this sequence matches the `Keys` sequence.

However the following code will raise an error OptionalValue.Value: is not available. Is this expected behaviour? I was expecting ValuesAll can return double.nan

#I "..\..\packages\Deedle.1.2.4"
#load "Deedle.fsx"
open System
open System.Globalization
open System.Collections.Generic
open Deedle

let ts = [DateTime.Now.Date => Double.NaN; DateTime.Now.Date.AddDays(1.0) => 1.0] |> series
ts.Print()
ts.ValuesAll
> 
27/01/16 12:00:00 AM -> <missing> 
28/01/16 12:00:00 AM -> 1         


val ts : Series<DateTime,float> =

27/01/16 12:00:00 AM -> <missing> 
28/01/16 12:00:00 AM -> 1         

val it : seq<float>

> ts.ValuesAll
;;
val it : seq<float> = Error: OptionalValue.Value: Value is not available
> 

Solution

  • There are different implementations for valuesAll here and C#-friendly ValuesAll here. The latter one just accesses the .Value property of optional value and its signature is seq<float>, not seq<float opt>. Either implementation or docs are not consistent here.

    When I used Deedle I filtered series with |> Series.dropMissing as a quick workaround when I needed only present values.