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

Add Dotnet interactive extension #547

Closed kMutagene closed 2 years ago

kMutagene commented 2 years ago

This PR adds a .NET interactive extension for deedle. This means you can end cells in .NET notebooks with a frame or series and you get a nicely formatted table.

This PR also adds column slicing to the standard formatting, as well as a function that returns the formatted strings per cell for usage in the extension.

I had to introduce new interfaces (IFrameFormattable, ISeriesFormattable) because dotnet interactive does not seem to be able to register formatters for e.g. Frame<_,_> without type annotation.

I also had to use strings instead of the html DSL of Dotnet.Interactive.Formatting.FSharp because that would need .NET 6, which is not supported due to global.json of this project.

See the poc notebook here: https://github.com/fslaborg/Deedle/blob/interactive/src/Deedle.Interactive/test.ipynb

done:

still to do:

kMutagene commented 2 years ago

I know that there is also https://github.com/WalternativE/Deedle.DotNet.Interactive.Extension but it seems not to be updated and i am too stupid to understand the code there, so i made this instead. It adapts and extends some Deedle internals instead of working on the IFsiFormattable interface. @WalternativE i would love your feedback on this. Are you still planning on working on that repo? maybe we can bundle efforts here.

WalternativE commented 2 years ago

I know that there is also https://github.com/WalternativE/Deedle.DotNet.Interactive.Extension but it seems not to be updated and i am too stupid to understand the code there, so i made this instead. It adapts and extends some Deedle internals instead of working on the IFsiFormattable interface. @WalternativE i would love your feedback on this. Are you still planning on working on that repo? maybe we can bundle efforts here.

Would be lovely to have something in the main repo. I didn't commit anything at this place because there were still open design questions and because of the 'unstable' nature of the .NET Interactive extension API. @kMutagene if there are problems with my extension, please feel free to open an issue. I'm currently daily driving R and Python (or F# in server code) so I'm pretty slow at recognizing if something breaks :/

zyzhu commented 2 years ago

@kMutagene, this looks awesome. As for global.json, that was just intended to keep all the dependencies working together. Feel free to get this upgraded to dotnet 6 if you get a chance, especially if you can get the docs revived with latest fsdocs tools.

Due to change of work obligation, I have much less time available on my hands to work on this. I trust that the repo is in great hands. đź‘Ť

kMutagene commented 2 years ago

@AndrewIOM is there more to do locally than install R 4.0.2 and create a R_HOME variable (which in my case points at C:\Program Files\R\R-4.0.2\bin) for building the RPlugin? It does not work for me. As a temporary fix, i have created build targets that ignore the RPlugin project. I will release this as beta packages once it's merged until this is figured out.

nhirschey commented 2 years ago

Update: Sorry, just noticed that RProvider is building on windows CI. Ignore everything below. Sorry!

@kMutagene FYI, regarding RProvider, I also noticed some issues building on windows (https://github.com/fslaborg/RProvider/issues/253). When I looked into it, my best guess for what changed from when I was previously able to build on windows was the runtime identifier change in RProvider.Server that was changed to be osx-64 see here.

I don't know, but it's possible that it blocks successful windows builds. I didn't investigate further.