Bokeh新手在这里发现一些学习示例对我不起作用。特别是,我正在TimeSeries
中使用index
并像{{}}那样设置t = TimeSeries(dt[dt['type'] == 0][['value', 'date']], index = 'date')
show(t)
:
index = 'data'
这会产生以下冗长的错误消息(当我删除上面的---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-93-af5f4a3c6c5e> in <module>()
2 print(dt[1:10])
3 dt.set_index('date')
----> 4 t = TimeSeries(dt[dt['type'] == 0][['value', 'date']], index = 'date')
5 show(t)
/Users/anaconda3/lib/python3.5/site-packages/bokeh/charts/builders/timeseries_builder.py in TimeSeries(data, x, y, builder_type, **kws)
100 kws['x'] = x
101 kws['y'] = y
--> 102 return create_and_build(builder_type, data, **kws)
/Users/anaconda3/lib/python3.5/site-packages/bokeh/charts/builder.py in create_and_build(builder_class, *data, **kws)
64 # create a chart to return, since there isn't one already
65 chart_kws = { k:v for k,v in kws.items() if k not in builder_props}
---> 66 chart = Chart(**chart_kws)
67 chart.add_builder(builder)
68 chart.start_plot()
/Users/anaconda3/lib/python3.5/site-packages/bokeh/charts/chart.py in __init__(self, *args, **kwargs)
112 # supported types
113 tools = kwargs.pop('tools', None)
--> 114 super(Chart, self).__init__(*args, **kwargs)
115
116 defaults.apply(self)
/Users/anaconda3/lib/python3.5/site-packages/bokeh/models/plots.py in __init__(self, **kwargs)
76 raise ValueError("Conflicting properties set on plot: background_fill, background_fill_color.")
77
---> 78 super(Plot, self).__init__(**kwargs)
79
80 def select(self, *args, **kwargs):
/Users/anaconda3/lib/python3.5/site-packages/bokeh/model.py in __init__(self, **kwargs)
81 self._id = kwargs.pop("id", make_id())
82 self._document = None
---> 83 super(Model, self).__init__(**kwargs)
84 default_theme.apply_to_model(self)
85
/Users/anaconda3/lib/python3.5/site-packages/bokeh/core/properties.py in __init__(self, **properties)
699
700 for name, value in properties.items():
--> 701 setattr(self, name, value)
702
703 def __setattr__(self, name, value):
/Users/anaconda3/lib/python3.5/site-packages/bokeh/core/properties.py in __setattr__(self, name, value)
720
721 raise AttributeError("unexpected attribute '%s' to %s, %s attributes are %s" %
--> 722 (name, self.__class__.__name__, text, nice_join(matches)))
723
724 def set_from_json(self, name, json, models=None):
AttributeError: unexpected attribute 'index' to Chart, possible attributes are above, background_fill_alpha, background_fill_color, below, border_fill_alpha, border_fill_color, disabled, extra_x_ranges, extra_y_ranges, h_symmetry, hidpi, left, legend, lod_factor, lod_interval, lod_threshold, lod_timeout, logo, min_border, min_border_bottom, min_border_left, min_border_right, min_border_top, name, outline_line_alpha, outline_line_cap, outline_line_color, outline_line_dash, outline_line_dash_offset, outline_line_join, outline_line_width, plot_height, plot_width, renderers, responsive, right, tags, title, title_standoff, title_text_align, title_text_alpha, title_text_baseline, title_text_color, title_text_font, title_text_font_size, title_text_font_style, tool_events, toolbar_location, tools, v_symmetry, webgl, x_mapper_type, x_range, xgrid, xlabel, xscale, y_mapper_type, y_range, ygrid, ylabel or yscale
时会消失)
dt
这里有什么问题,如何解决?作为参考,这里有一些 value type date index
1 0.55 1 2016-04-12 06:00:00+00:00 1
2 0.55 1 2016-04-12 11:30:00+00:00 2
3 0.55 1 2016-04-12 06:30:00+00:00 3
4 0.55 1 2016-04-12 12:00:00+00:00 4
5 0.55 1 2016-04-12 12:30:00+00:00 5
6 0.55 1 2016-04-12 08:00:00+00:00 6
7 0.55 1 2016-04-12 08:30:00+00:00 7
8 0.55 1 2016-04-13 07:30:00+00:00 8
9 0.55 1 2016-04-12 13:00:00+00:00 9
行打印出来:
for t in range(0,2): #Refers to txt file with ids
address = 'http://www.tspc.oregon.gov/lookup_application/LDisplay_Individual.asp?id=' + lines2[t]
page = requests.get(address)
tree = html.fromstring(page.text)
count = 0
for license_row in tree.xpath(".//tr[td[1] = 'License Type']/following-sibling::tr[1]"):
license_data = license_row.xpath(".//td/text()")
count = count + 1
if count==1:
ltest1.append(license_data)
if count==2:
ltest2.append(license_data)
if count==3:
ltest3.append(license_data)
with open('teacher_lic.csv', 'wb') as pensionfile:
writer = csv.writer(pensionfile, delimiter="," )
writer.writerow(["Name", "Lic1", "Lic2", "Lic3"])
pen = zip(lname, ltest1, ltest2, ltest3)
for penlist in pen:
writer.writerow(list(penlist))