Hello!
I have the following dataframe:
Date Impressions Link_Clicks
2017-05-29 00-00-00 1,492,046 8,093
2017-06-05 00-00-00 845,012 4,864
2017-06-12 00-00-00 1,167,100 6,897
2017-06-19 00-00-00 895,781 4,472
2017-06-26 00-00-00 1,037,839 9,518
2017-07-03 00-00-00 1,139,060 9,668
2017-07-10 00-00-00 1,235,760 9,268
2017-07-17 00-00-00 1,200,906 7,989
2017-07-24 00-00-00 1,214,534 6,991
2017-07-31 00-00-00 1,434,225 7,311
2017-08-07 00-00-00 557,393 2,908
I am trying to visualise this using Bokeh which I’ve managed to do successfully, however when implementing the hover-tool, it returns the number divided specifically by 2. Is this a bug?
Libraries used:
from bokeh.io import output_notebook, show, push_notebook
from bokeh.io import output_file, show, curdoc
output_notebook()
from bokeh.plotting import figure, ColumnDataSource
from bokeh.models import HoverTool, DatetimeTickFormatter, DataRange1d, CustomJS, Plot, LinearAxis, Grid
from bokeh.charts import Bar, BoxPlot, Donut, HeatMap, Histogram, Line, Scatter, TimeSeries
My code can be found below:
source = ColumnDataSource(data=dict(
desc = bar_df.index,
y = bar_df[“Link_Clicks”],
))
p = Bar(bar_df, label=bar_df.index, values=“Link_Clicks”, width=1, source=source, agg=‘sum’,
line_color=“white”, plot_width=900, plot_height=400, bar_width=0.9, legend=None, toolbar_location=“right”)
p.add_tools(HoverTool(tooltips=[(“Link_Clicks”, “@y{1.11}”),
(“Date”, “@index”)]))
p.xaxis.major_label_orientation = 45
show(p)
NOTE: if you try and replicate this, dates for Bokeh can’t be in DateTime format; only strings.
To quickly convert: df[“Date”] = df[“Date”].apply(lambda x: str(x).replace(’:’,’-’))
When hovering over, you can see this is divided perfectly by 2 which is strange. I have tried multiplying y*2 under ColumnDataSource and within the Hover Tool, but still no luck.
Any ideas?