Skip to content
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

vega-lite-api & nodejs-polars #3897

Open
BorisTherin opened this issue Mar 22, 2024 · 6 comments
Open

vega-lite-api & nodejs-polars #3897

BorisTherin opened this issue Mar 22, 2024 · 6 comments

Comments

@BorisTherin
Copy link

BorisTherin commented Mar 22, 2024

Hi awesome team.

I'm working on a jupyterlab notebooks project with nodesjs-polars (with deno kernel), and sounds like vega-lite-api does not support polars dataframe.
Unfortunatly, nodejs-polars does not provide the to_pandas() method (like the python version).

As far as feature parity goes. Ideally i'd like to write some scripts that generate a coverage map between node & python features. We know some features will be much more difficult to support in JS (if not impossible). (lambdas, and interop methods [pandas, arrow]). But until we have some automated way of tracking this, it is a manual task to update the features to match py-polars.
from pola-rs/nodejs-polars#30

so atm i have to pass my dataframe to vega-ite-api with nodejs-polars writeCSV() method this way.

const response = await fetch("https://raw.githubusercontent.com/vega/vega/main/docs/data/gapminder-health-income.csv")
const data = await response.text()
const df = pl.readCSV(data)

/*
    our every polars manipulations
*/

const plot = vl
    .markCircle()
    .params(vl.selectInterval().bind("scales"))
    .width(700)
    .data(
        df.writeCSV()   // convert to CVS buffer
    )
    .encode(
        vl.x().field("income").scale({ type: "log"}),
        vl.y().fieldQ("health").scale({zero: false}).axis({ minExtent: 30 }),
        vl.size(vl.fieldQ("population")),
        vl.color({ value: "#262696" }),
    );
display(plot) 

if i try to pass polars original dataframe .data(df) it do crash my deno kernel every time
image

is polars (actually nodes-polars) dataframe aimed to be suport by vega-lite-api in the project's roadmap ?
or am i doing something wrong by my side ?

@domoritz
Copy link
Member

Vega-Lite supports arrow so could you export the underlying arrow from polars?

@BorisTherin
Copy link
Author

from nodejs-polars issue vega/vega-lite-api#30
We know some features will be much more difficult to support in JS (if not impossible). (lambdas, and interop methods [pandas, arrow]).
pandas & arrow are not supported in the nodejs version atm, and the (if not impossible) comment doesnt sounds very good here

when i seach for to_XXX_ method in nodejs-polars documentation:
image

So, having to convert my polar dataframe back into cvs with pl.writeCSV() is not that dramatic, but i will have to defend vega-lite-api use in this project to my team, and knowing if it will be supported would help. polars (actually nodejs-polars) will not be negociable as we will need very large dataset to work with, & polars is the only one providing dataframe larger than our ram.

@jheer
Copy link
Member

jheer commented Mar 22, 2024

It looks like this concerns Vega-Lite or really Vega. If Vega can support Polars then it will be easy to update this API to pass that through, just like other data formats.

@domoritz should we transfer out of vega-lite-api for better tracking?

@BorisTherin
Copy link
Author

@jheer yes, as polars python version does suppot to_pandas everyhting was fine, but sounds like the javascript side as been forgotten when nodejs-polars cant provide such a function

@domoritz domoritz transferred this issue from vega/vega-lite-api Mar 22, 2024
@domoritz
Copy link
Member

Moved to Vega

@BorisTherin
Copy link
Author

thx for help and very quick response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants