Incorrect datetime format on hovertool with python bokeh

Woodz

I've got a issue with the datetime format on my hovertool. I'm not sure but i think since i've updated bokeh and pandas to the latest version (bokeh: v2.0.1 / pandas v1.0.3) in conda the presentation of the dates in my bokeh plot are faulty.

import pandas as pd

# first of all i create a columndatasource and convert my datetime-strings to pandas datetime-objects:

Source = ColumnDataSource(data={'date' : pd.to_datetime(df_data['Date'], format='%Y-%m'), 
                                'values' : df_data['values']})

#print(pd.to_datetime(df_data['Datum'], format='%Y-%m'))
# >>>
#0 1980-01-01
#1 1980-02-01
#2 1980-03-01
#...

hover = HoverTool(tooltips = [('Month', '@date{%b, %Y}'),('Value', '@values{0.0} °C')],
formatters = {'date' : 'datetime'}, mode='vline')

plot = figure(x_axis_label='time',
              x_axis_type='datetime',
              y_axis_label='diff',
              tools = [hover, 'pan', 'box_zoom', 'wheel_zoom', 'reset'],
              background_fill_color = '#2F4F4F',
              output_backend="webgl",
              toolbar_location='right',
              title="Title")


plot.vbar(x = 'Month',top = 'Value', source=Source, width=timedelta(days=20), color='color')

But if i run this, it shows me for "Month" in my hovertool something like "80TiB %" and not "Apr 2020".

bigreddot

The key in the formatters dictionary has to match the field specification exactly, including any prefix:

formatters = {'@date' : 'datetime'}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Using Hovertool in Python with Bokeh

Formatting Pandas datetime in Bokeh HoverTool

Python Bokeh tool - How to display hovertool with datetime formatter xaxis from bokeh?

Python Bokeh HoverTool formatters error: "unexpected attribute 'formatters' to HoverTool"

Bokeh (Python): Format DateTime in Hover tooltip

Why is my hovertool, from bokeh showing incorrect results?

How to add HoverTool to a Data Table (Bokeh, Python)

Bokeh HoverTool custom font and newlines from Python

Adding hovertool to a second Y axis with bokeh python

Change bokeh python hovertool tooltip layout

VBS incorrect datetime format

Bokeh Hovertool for patch

Bokeh HoverTool Shows "???"

Bokeh Hovertool stacked barchart

Euro sign in Bokeh HoverTool [Solved]

Bokeh Hovertool for second plot in a figure

Display hovertool for the uppermost glyph in bokeh?

Hovertool Bokeh "Cannot read property"

Invalid datetime format: 1292 Incorrect datetime value

Bokeh cannot change datetime axis format

Format text alignment within Bokehs HoverTool/tooltips - Python

Invalid datetime format: 1366 Incorrect string value

DateTime to string format returning incorrect result

Datetime library in Python giving incorrect format for YYYY-MM-DD resulting in error after embedding in API call

HoverTool for multiple data series in bokeh scatter plot

Bokeh: how to turn HoverTool on/off from callback?

Picking data for Bokeh HoverTool output from ColumnDataSource

Bokeh- hovertool does not reflect CDSView in heatmap

Bokeh: Images for hovertool doen't show