【发布时间】:2019-01-03 11:27:23
【问题描述】:
我正在尝试从一个包含两列的简单 CSV 文件绘制折线图,使用 Bokeh 进行数据可视化,使用 Panda 读取 CSV 并处理数据。但是,我似乎无法将使用 pandas 导入的数据传递给 Bokeh 来绘制我的折线图。
这是在我的计算机上本地运行的。我已经尝试并调试了代码的每个部分,当我将数据从熊猫传递到散景时,似乎出现了唯一的问题。
我已尝试打印从 csv 中选择的列,以检查是否也选择了整个列。
#Requirements for App
from bokeh.plotting import figure, output_file, show
import pandas as pd
from bokeh.models import ColumnDataSource
#Import data-->Weight measurements over a period of time [ STUB ]
weight = pd.read_csv("weight.csv")
#Define parameters
x=weight["Date"]
y=weight["Weight"]
#Take data and present in a graph
output_file("test.html")
p = figure(plot_width=400, plot_height=400)
p.line(x,y,line_width=2)
show(p)
我希望得到一个绘制每天每个重量条目的折线图,但我得到一个空白图。
【问题讨论】: