Altair 无法访问文件系统以在 Google Colab 上呈现大型数据集

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

我正在尝试在 Google Colab 上使用 Altair 从单个大型数据集生成大量图表。为了提高性能,我想实施推荐的解决方案之一 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。有什么方法可以提供这些文件以启用所需的行为吗?

https://altair-viz.github.io/user_guide/faq.html#maxrowserror-how-can-i-plot-large-datasets 所述,json 转换器无法在基于云的 Jupyter 环境中运行。

对于 Colab,解决问题的最简单方法是使用 altair_data_server。只是 运行 以下内容:

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

(注意:'data_server_proxied' 在 Colab 中不工作,但 'data_server' 可以)。

有关详细信息,请参阅位于 https://colab.research.google.com/github/altair-viz/altair_data_server/blob/master/AltairDataServer.ipynb

altair_data_server Colab 示例笔记本