我正在尝试使用Bokeh绘制一个包含年份和数字列的Pandas数据框DateTime.如果DateTime指定为x,则行为是预期的(x轴上的年份).但是,如果我用set_index打开DateTime列入数据帧的指数,那么只有指定y的TimeSeries在x轴毫秒我得到的时间.一个最小的例子
import pandas as pd
import numpy as np
from bokeh.charts import TimeSeries, output_file, show
output_file('fig.html')
test = pd.DataFrame({'datetime':pd.date_range('1/1/1880', periods=2000),'foo':np.arange(2000)})
fig = TimeSeries(test,x='datetime',y='foo')
show(fig)
output_file('fig2.html')
test = test.set_index('datetime')
fig2 = TimeSeries(test,y='foo')
show(fig2)
Run Code Online (Sandbox Code Playgroud)
这是预期的行为还是错误?我希望两种方法都有相同的图片.
干杯!!