machump
machump

Reputation: 1267

bokeh x-axis datetime returning incorrect dates

I have a dataframe df2 with dates in string form and numbers

date       |    value
2018-02-02    130
2018-02-05    360
2018-02-06    98
2018-02-07    150

When I plot the dates in a plot along the x axis, the dates returned are incorrect. They seem to translate like so:

2018-02-06 = Jan 1, 1970 2018-02-05 = Jan 13.5, 1970

source=ColumnDataSource(data=df2)
p= figure(plot_width=700, plot_height=400, x_axis_type="datetime")
p.xaxis.formatter= DatetimeTickFormatter(days="%B/%d/%Y")
p.triangle("DATE","VALUE",color='black',source=source)

The glyphs don't fall exactly on the gridlines either. What is happening?

Upvotes: 0

Views: 285

Answers (1)

machump
machump

Reputation: 1267

p.triangle(df2["DATE"].dt.date,df2["VALUE"],color='Black') will yield the date

I have a nasty habit of finding the right answers shortly after posting it on stackoverflow. I think I may do that more often!

Upvotes: 0

Related Questions