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

Frame.toArray2D throws a System.Format exception #540

Closed kurt-mueller-osumc closed 2 years ago

kurt-mueller-osumc commented 2 years ago
> frame |> Frame.toArray2D;;
System.FormatException: Input string was not in a correct format.
   at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
   at System.String.System.IConvertible.ToDouble(IFormatProvider provider)
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Deedle.Internal.Convert.convertType[T](ConversionKind conversionKind, Object value) in C:\FSharp\fslaborg\Deedle\src\Deedle\Common\Common.fs:line 1440
   at Deedle.VectorHelpers.convertType@273-3.Invoke(T value) in C:\FSharp\fslaborg\Deedle\src\Deedle\Vectors\VectorHelpers.fs:line 273
   at Deedle.F# Vector extensions (core).IVector-1-Select@127.Invoke(IVectorLocation _arg1, OptionalValue`1 input)
   at <StartupCode$Deedle>.$ArrayVector.data@380-6.Invoke(Int32 i, T v) in C:\FSharp\fslaborg\Deedle\src\Deedle\Vectors\ArrayVector.fs:line 380
   at Microsoft.FSharp.Collections.ArrayModule.MapIndexed[T,TResult](FSharpFunc`2 mapping, T[] array) in D:\a\_work\3\s\src\fsharp\FSharp.Core\array.fs:line 351
   at Deedle.Vectors.ArrayVector.ArrayVector`1.Deedle.IVector<'T>.Select[TNewValue](FSharpFunc`2 f) in C:\FSharp\fslaborg\Deedle\src\Deedle\Vectors\ArrayVector.fs:line 380
   at Deedle.VectorHelpers.toArray2D@409.Invoke(Int32 c, OptionalValue`1 vector) in C:\FSharp\fslaborg\Deedle\src\Deedle\Vectors\VectorHelpers.fs:line 412
   at Microsoft.FSharp.Collections.SeqModule.IterateIndexed[T](FSharpFunc`2 action, IEnumerable`1 source) in D:\a\_work\3\s\src\fsharp\FSharp.Core\seq.fs:line 523
   at Deedle.VectorHelpers.toArray2D[R](Int32 rowCount, Int32 colCount, IVector`1 data, Lazy`1 defaultValue) in C:\FSharp\fslaborg\Deedle\src\Deedle\Vectors\VectorHelpers.fs:line 409
   at Deedle.Frame`2.ToArray2D[R]() in C:\FSharp\fslaborg\Deedle\src\Deedle\Frame.fs:line 710
   at <StartupCode$FSI_0016>.$FSI_0016.main@()
Stopped due to error

I can view the series values in the console... I just can't convert them to a 2d array for some reason.

tpetricek commented 2 years ago

df |> Frame.toArray2D attempts to convert all data in the frame to float, so if you have non-numeric data, this won't work

If you have other types of data in your frame, you can us df.ToArray2D<obj>() which lets you specify the target type of the array (here obj which should work for any kind of data).