Chain_Reaktion
Chain_Reaktion

Reputation: 63

Altair can't access filesystem to render large datasets on Google Colab

I'm trying to generate a large number of plots from a single large dataset using Altair on Google Colab. To improve performance, I would like to implement one of the solutions recommended here. However, so far none have been successful. Ideally I would like to use the json data_transformer, but this leads to 404 and 500 errors as pictured here. Is there any way I can serve these files to enable the desired behavior?

Upvotes: 3

Views: 519

Answers (1)

jakevdp
jakevdp

Reputation: 86513

As mentioned at https://altair-viz.github.io/user_guide/faq.html#maxrowserror-how-can-i-plot-large-datasets, the json transformer will not work on cloud-based Jupyter environments.

For Colab, the easiest approach to solving your problem is to use altair_data_server. Just run the following:

!pip install altair_data_server
alt.data_transformers.enable('data_server')

(NB: 'data_server_proxied' does not work in Colab, but 'data_server' does).

For more information, see the altair_data_server Colab example notebook at https://colab.research.google.com/github/altair-viz/altair_data_server/blob/master/AltairDataServer.ipynb

Upvotes: 3

Related Questions