Date time format in Hovertool

Hi

Can anyone please please tell me how to get a nice date time format in Hovertool.

I have a plot with beautifully formatted datetime on the x axis, but in the Hovertool the timestamp just comes up as a unix Epoch time, and I cannot find out how to format it.

Would be so grateful for advice

Cathy

Hi Cathy

I’ve used this workaround:

source = ColumnDataSource(df)

source.add(df[‘event_date’].apply(lambda d: d.strftime(’%Y-%m-%d’)), ‘event_date_formatted’)

hover = HoverTool(

tooltips=[

(‘date’, ‘@event_date_formatted’),

other attributes …

]

)

It’s adding a new column to the ColumnDataSource called ‘event_date_formatted’ which is a string representation of df[‘event_date’], then uses that as a field in the tooltip. Here df is a Pandas DataFrame. You could achieve the same with a list and a map function.

Hope this helps.

Dennis

···

On Tue, Feb 16, 2016 at 2:36 PM Catmo [email protected] wrote:

Hi

Can anyone please please tell me how to get a nice date time format in Hovertool.

I have a plot with beautifully formatted datetime on the x axis, but in the Hovertool the timestamp just comes up as a unix Epoch time, and I cannot find out how to format it.

Would be so grateful for advice

Cathy

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0a323110-2a2b-478d-9052-fe519e65a413%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Dennis

Thank you so much - that works perfectly!

Best wishes & blessings that all your software bugs get fixed in deserving good karma,

Cathy

···

On Wednesday, 17 February 2016 06:30:44 UTC, Dennis O’Brien wrote:

Hi Cathy

I’ve used this workaround:

source = ColumnDataSource(df)

source.add(df[‘event_date’].apply(lambda d: d.strftime(’%Y-%m-%d’)), ‘event_date_formatted’)

hover = HoverTool(

tooltips=[

(‘date’, ‘@event_date_formatted’),

other attributes …

]

)

It’s adding a new column to the ColumnDataSource called ‘event_date_formatted’ which is a string representation of df[‘event_date’], then uses that as a field in the tooltip. Here df is a Pandas DataFrame. You could achieve the same with a list and a map function.

Hope this helps.

Dennis

On Tue, Feb 16, 2016 at 2:36 PM Catmo [email protected] wrote:

Hi

Can anyone please please tell me how to get a nice date time format in Hovertool.

I have a plot with beautifully formatted datetime on the x axis, but in the Hovertool the timestamp just comes up as a unix Epoch time, and I cannot find out how to format it.

Would be so grateful for advice

Cathy

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0a323110-2a2b-478d-9052-fe519e65a413%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.