Add functions to convert between jagged arrays and frames#532
Add functions to convert between jagged arrays and frames#532zyzhu merged 5 commits intofslaborg:masterfrom kMutagene:master
Conversation
| invalidOp "FromJaggedArray: The input jagged array must have the same dimensions in all inner arrays." | ||
| else | ||
| let arr2D = Array2D.init jArray.Length jArray.[0].Length (fun r c -> jArray.[r].[c]) | ||
| Frame.FromArray2D(arr2D) |
There was a problem hiding this comment.
creating a frame like that doesn't look effective . We create a copy of array just to pass it further? We can easily do the same even now
jArray |> array2D |> Frame.FromArray2DThere was a problem hiding this comment.
I was not thinking about performance here, as I see the frame creation as a step that only happens a single time in a data analysis pipeline, but i can definitely adjust this to work exactly as the FromArray2D function.
We can easily do the same even now
jArray |> array2D |> Frame.FromArray2D
Agreed, but the whole point of this PR is to get rid of the function in the middle. And where is the array2D from this example coming from anyways? I cant find it in FSharp.Core and needing an external library for that or having to do the copy in the analysis is exactly what i want to prevent.
There was a problem hiding this comment.
And where is the array2D from this example coming from anyways
that's from FSharp.Core
There was a problem hiding this comment.
Well that was a brainfart on my side :D sorry.
There was a problem hiding this comment.
I used the same code now that is used in FromArray2D so I think it should be now more performant either way
|
It's indeed a convenience function, especially from C# as there is no helper function |
|
@kMutagene, I've released 2.4.1. BTW, would you like to be a co-maintainer of this project? As you are the main contributor to FsLab ecosystem, it could help you to iterate faster. |
|
@zyzhu sure, that would be great! |
|
That's great! Just added you as maintainer of the project now. I also sent you invitation on nuget. |
Content
This PR adds functions to:
FromJaggedArrayfor C#,ofJaggedArrayfor F#toJaggedArray<'R>for any type of conversion for the frame data (returns 'R[][])Frame.toJaggedArrayto return afloat [][]analogously toFrame.ToArray2DWhy?
These are simply convenience functions that improve interop with Plotly.NET. I often handle data frames with numeric values only, where i want to visualize the contents after some transformations with Deedle. Charts that accept two-dimensional data in Plotly.NET expect data as jagged arrays, so i would love to see this added as it prevents a clunky conversion step from the
Array2Dobtained byFrame.ToArray2Dand the chart initialization.additional notes
The build fails for me with an outdated log format, so i updated build dependencies and fake as well, if that breaks anything please let me know.