create built in way to visualize dataframe in Jupyter#132
create built in way to visualize dataframe in Jupyter#132universalmind303 merged 1 commit intopola-rs:mainfrom
Conversation
|
Note: I could not actually build this branch due to an issue with local builds, as mentioned on Discord. Hey all! I'm trying to make a PR to nodejs-polars and haven't been able to figure out how to get the toolchain working well: Does anyone else run into this or know how to get to a decent state for a local build on MacOS? I'm extremely new to Rust so I might be missing something super simple. |
|
@rgbkrk please run "yarn run lint:ts:fix" on your PR and push the changes. Thx |
159d97b to
3bc117e
Compare
Done. |
|
@rgbkrk Do you want to add some documentation around this feature? Thx |
|
Totally. Where do you want it? Other than the README I'm only seeing jsdocs. |
|
Probably in the Readme below webpack, unless you find a better place. Thx |
|
README is a great start! I'll get that submitted soon. In a separate PR I'd love to get some user guides together to help people get started with polars in JavaScript / Typescript. |
|
Done! Let me know what you think. |
|
LGTM, but I am just wondering 2 things:
|
Isn't... that what this library is? I use Python everyday. There are also a lot of JavaScript developers out there and you've all made something that is really solid interop between the javascript ecosystem and arrow underneath. I can use D3 directly with Polars DataFrames to visualize data. In this example polars notebook, I'm able to pass columns directly to D3 to create the scales I need, server side.
I'm ready to enable JavaScript developers to use polars. |
|
I think this library is more for backend service use in Node/Bun/Deno then DS, but that's for community to decide. :) |
universalmind303
left a comment
There was a problem hiding this comment.
great work @rgbkrk. Really excited to see more data science & analytics tools embracing JS. (_ I personally strongly dislike python syntax_).
Also excited to see that polars works on deno now. I tried using polars with deno a long time ago & it was unsupported.
Just a few small comments on the PR.
b7de10f to
1d6df04
Compare
universalmind303
left a comment
There was a problem hiding this comment.
Can we add a test for this? otherwise looks like it's good to go!
|
@universalmind303 Do we need a CI test using |
8c13b63 to
e85692c
Compare
|
Thanks again @rgbkrk. I'm very excited to see more JS + notebook integrations maturing. |
|
Thank you for the review and the stewardship of polars for JavaScript! I'm excited to see what people can do with this. |


Hi! 👋🏻
This introduces a basic way to display Polars DataFrames from a deno kernel in a Jupyter Notebook.
While I've baked it into
display.js, which is on its way to be part ofDenoitself (denoland/deno#20819), I'd love to get a solid implementation inside ofnodejs-polars. There are two mediatypes exported here via the Rich Content Output Symbol,Symbol.for("Jupyter.display")text/html- a standard static table we're all pretty used toapplication/vnd.dataresource+json- Row oriented JSON for frontends to implement scrollable grids for a table (and additional data visualization).Here's an example of what's possible with the data resource media type:
Blog post featuring
nodejs-polars: https://blog.jupyter.org/bringing-modern-javascript-to-the-jupyter-notebook-fc998095081eOnce this is in I'll update the blog post screenshots to use the implementation that relies on
nodejs-polars.Background on the Data Resource Schema
Using the schema from https://specs.frictionlessdata.io/schemas/tabular-data-resource.json, we can emit a format that frontends can use for much richer tables.
As an example, in
pandasyou enable it with:and then just type
dfin cells. Here's some more sample (python) code for looking at this format{ "schema": { "fields": [ { "name": "index", "type": "integer" }, { "name": "species", "type": "string" }, { "name": "island", "type": "string" }, { "name": "bill_length_mm", "type": "number" }, { "name": "bill_depth_mm", "type": "number" }, { "name": "flipper_length_mm", "type": "number" }, { "name": "body_mass_g", "type": "number" }, { "name": "sex", "type": "string" }, { "name": "year", "type": "integer" } ], "primaryKey": [ "index" ], "pandas_version": "1.4.0" }, "data": [ { "index": 0, "species": "Adelie", "island": "Torgersen", "bill_length_mm": 39.1, "bill_depth_mm": 18.7, "flipper_length_mm": 181.0, "body_mass_g": 3750.0, "sex": "male", "year": 2007 }, { "index": 1, "species": "Adelie", "island": "Torgersen", "bill_length_mm": 39.5, "bill_depth_mm": 17.4, "flipper_length_mm": 186.0, "body_mass_g": 3800.0, "sex": "female", "year": 2007 }, { "index": 2, "species": "Adelie", "island": "Torgersen", "bill_length_mm": 40.3, "bill_depth_mm": 18.0, "flipper_length_mm": 195.0, "body_mass_g": 3250.0, "sex": "female", "year": 2007 }, { "index": 3, "species": "Adelie", "island": "Torgersen", "bill_length_mm": null, "bill_depth_mm": null, "flipper_length_mm": null, "body_mass_g": null, "sex": null, "year": 2007 }, { "index": 4, "species": "Adelie", "island": "Torgersen", "bill_length_mm": 36.7, "bill_depth_mm": 19.3, "flipper_length_mm": 193.0, "body_mass_g": 3450.0, "sex": "female", "year": 2007 } ] }