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

public facing method to update a dataset in place #3318

Open
mattijn opened this issue Jan 24, 2024 · 1 comment
Open

public facing method to update a dataset in place #3318

mattijn opened this issue Jan 24, 2024 · 1 comment

Comments

@mattijn
Copy link
Contributor

mattijn commented Jan 24, 2024

As was shown by @jonmmease mease in this comment: #3281 (comment) it is possible to update a full dataset in place within the alt.JupyterChart class. Currently this is possible using a primitive function jchart._py_to_js_updates().

What would an intuitive public facing method look like?
My current feeling is to do it similar to the jchart.params.

So if you do jchart.data you would get an overview of the available datasets within the specification.
The names of the datasets are also registered as attributes of jchart.data and using this method we also could assign the dataset as such:

jchart.data.data_a0e7a86c692327a18bbeb2464725124c = df_update.to_dict("records")

(currently there is a dash instead of an underscore in the dataset name)

The current default behavior of altair is to try to collect all datasets globally within datasets, so a default scope of [] should be fine in almost all occasions I think.

Other ideas are welcome too!

Edit: or jchart.datasets instead of jchart.data

@joelostblom
Copy link
Contributor

I agree that having a public method for this would be convenient and I like your suggestion. I think it would be preferred over something like jchart.update_data('a0e7a86c692327a18bbeb2464725124c', df_update.to_dict("records") since users would likely already be using jchart.data to explore which ID to update. Are there any advantages that come to mind with having a function for updating the data instead of an assignment as in your suggestion? Maybe if one wants to do the update as part of list comprehension (although I think we can use the walrus operator for that nowadays)?

I think adding this feature would close #435.

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

No branches or pull requests

2 participants