【问题标题】:How do I import a CSV in Bokeh as a ColumnDataSource without going through Pandas?如何在不通过 Pandas 的情况下将 Bokeh 中的 CSV 作为 ColumnDataSource 导入?
【发布时间】:2017-08-13 17:29:21
【问题描述】:

要在 Bokeh 中使用数据集,通常还要导入 pandas 并使用 Pandas DataFrame 作为数据。也可以从 Pandas DataFrame 创建 ColumnDataSource。

但是是否可以直接从 csv 文件(或任何其他表格源数据)转到 Bokeh 而无需使用 Pandas 作为桥梁,以及如何?

【问题讨论】:

    标签: bokeh


    【解决方案1】:

    Bokeh ColumnDataSource 直接从 python 字典构建。只需使用:

    ColumnDataSouce(data=dict(...))
    

    在不知道您的具体数据格式的情况下,我建议您使用 SO 上的许多其他答案来读取 csv 文件和创建 Python 字典。您还可以查看DictReader 上的official docs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-16
      • 2021-06-04
      • 2021-09-16
      • 1970-01-01
      相关资源
      最近更新 更多