In [4]:
import pandas as pd
import numpy as np
from bokeh.io import show, output_notebook
from bokeh.plotting import figure
from bokeh.models import ColumnDataSource, HoverTool, DatetimeTickFormatter
from collections import OrderedDict
output_notebook()
In [5]:
dates = pd.date_range('2014/09/01 00:00', freq='H', periods=24, tz='Europe/Berlin')
data = pd.DataFrame(list(range(0,24)), dates, columns=['hour'])
data['with_tz'] = data.index
data['no_tz_str'] = [i.strftime('%Y-%m-%d %H:%M:00') for i in data.index]
data.reset_index(inplace=True)
data = data[['hour', 'with_tz', 'no_tz_str']]
data.head()
Out[5]:
In [6]:
# With TZ string
tz_df = data[['hour', 'with_tz']]
tz_df = tz_df.rename(columns={
'with_tz': 'time',
})
tz_source = ColumnDataSource(tz_df)
tz_df.head()
Out[6]:
In [7]:
tz_source.data['time'][0:5]
Out[7]:
In [12]:
pwith = figure(x_axis_type="datetime", tools='', plot_width=900)
f = ["%d-%b %H:%M %Z"]
pwith.xaxis.formatter = DatetimeTickFormatter(formats={"months": f, "days": f, "hours": f})
pwith.yaxis.axis_label = 'hour'
pwith.xaxis.axis_label = 'timestamp'
pwith.line(x='time', y='hour', source=tz_source, legend='with_tz', color='pink')
show(pwith)
In [ ]: