【发布时间】:2019-10-06 07:49:43
【问题描述】:
我在 google colab 中使用 altair 进行绘图。我已经达到了“最大行”警告:https://altair-viz.github.io/user_guide/faq.html#maxrowserror-how-can-i-plot-large-datasets。
这是我的数据集的头部:df.head()
所以现在我正在尝试通过 URL 传递数据,喜欢我的 googleDrive: 首先我将文件导出到我的驱动器:
"change directory and export whole csv "
os.chdir(Directory.table_dir)
one.to_json('one.json', orient='records')
然后我尝试使用 URLData 方法:https://altair-viz.github.io/user_guide/generated/core/altair.UrlData.html#altair.UrlData
os.chdir(Directory.table_dir)
#checking if i can read the file to a pandas dataframe
df=pd.read_json('one.json', orient='records')
source=alt.UrlData('content/gdrive/My Drive/SCTFT/Tables/one.json')
chart = alt.Chart(source).mark_point().encode(
x='VG:Q',
y='absID:Q',
color='file:N',
)
chart
我也试过了:
source='content/gdrive/My Drive/SCTFT/Tables/one.json'
使用 df 从 matplotlib 绘图有效。
但是从 altair 我得到: altair plot
我没有收到任何错误消息。 我应该改变我导出文件的方式吗?或者我如何将它与 URL 链接?
使用新信息进行编辑我从https://colab.research.google.com/github/altair-viz/altair_data_server/blob/master/AltairDataServer.ipynb 运行代码 :pip install first graph
它一直有效,直到:
这只是我在没有做任何更改的情况下运行笔记本,所以我的 colab 的设置方式一定有问题?
【问题讨论】:
标签: python json google-colaboratory altair