fslaborg / Deedle

Easy to use .NET library for data and time series manipulation and for scientific programming
http://fslab.org/Deedle/
BSD 2-Clause "Simplified" License
924 stars 196 forks source link

InvalidOperationException from Series.ValuesAll #376

Closed goerch closed 5 years ago

goerch commented 6 years ago

The following program

using Deedle;
using System;
using System.Linq;

namespace Bug2
{
    class Program
    {
        static void Main(string[] args)
        {
            var df =
                new FrameBuilder.Columns<int, string> {
                { "first", new SeriesBuilder<int, string> { {0, "1"}, {1, null} }.Series },
                { "second", new SeriesBuilder<int, string> { {0, "2"}, {1, "4"} }.Series }
            }.Frame;
            Console.WriteLine(df["first"].ValuesAll.Count());
        }
    }
}

generates an InvalidOperationException with message {"OptionalValue.Value: Value is not available"}

Is this expected behaviour?

alexpantyukhin commented 5 years ago

I guess it happens because this check there . For now it will not allow to pass null values.

zyzhu commented 5 years ago

Fixed. ValuesAll will call ValueOrDefault which will replace missing value with Unchecked.defaultof<'T>. In the case of missing float, it shall be replaced with 0.0