-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functions to convert between jagged arrays and frames #532
Conversation
src/Deedle/FrameExtensions.fs
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.FromArray2D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And where is the array2D from this example coming from anyways
that's from FSharp.Core
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that was a brainfart on my side :D sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
FromJaggedArray
for C#,ofJaggedArray
for F#toJaggedArray<'R>
for any type of conversion for the frame data (returns 'R[][])Frame.toJaggedArray
to return afloat [][]
analogously toFrame.ToArray2D
Why?
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
Array2D
obtained byFrame.ToArray2D
and 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.