I read csv having many columns including a Date column, as pandas dataframe called ‘breakageDf’.
Being ‘object’ type I convert the date column to string first then to datetime object
breakageDf["Date"] = breakageDf["Date"].astype("str")
breakageDf["Date"] = pd.to_datetime(breakageDf["Date"], format="%d-%m-%Y")
``
Then I set this Date column as index.
breakageDf = breakageDf.set_index("Date")
``
I wish to create a Bokeh line plot with Date as X axis and some other column values as Y axis.
p = figure(x_axis_type="datetime", width=w, height=h, tools=[hover, 'pan', 'wheel_zoom'])
p.line(breakageDf.index, breakageDf["BreakageValue"], color="#A6CEE3", legend="BreakageValue")
``
But the plot comes wrong. There is no spread on X axis at all.
Index when printed looks like
DatetimeIndex(['2015-03-05', '2015-03-07', '2015-03-10', '2015-03-11',
'2015-03-12', '2015-03-12', '2015-03-15', '2015-03-15',
'2015-03-15', '2015-03-20',
...
'2016-02-21', '2016-02-23', '2016-02-26', '2016-02-27',
'2016-02-28', '2016-03-08', '2016-03-14', '2016-03-15',
'2016-03-17', '2016-03-18'],
dtype='datetime64[ns]', name='Date', length=192, freq=None)
``
Is frequency being None, is the reason? Should it be Daily? How to set it programmatically? Or am I missing anything?