I have a table as follows:
np.random.seed(42)
df = pd.DataFrame(np.random.randint(0, 1000, size=(24,53)))
df['hour'] = range(24)
for col in df.columns[:-1]:
df.rename({col: str(col)}, axis=1, inplace=True)
which I want to plot. Columns (except hour) correspond to weeks of the year and rows to hours of the day. Directly using pandas it would be:
df[df.columns[:-1]].plot(legend=False);
yielding:
However, I want to add interactivity into the game. I thought of using bokeh but it changes so rapidly, I don't know how to do it now. I tried using holoviews:
import holoviews as hv
hv.extension('bokeh')
%%opts Curve [tools=['hover']]
lines = [hv.Curve((df['hour'], df[col]), label=col) for col in df.columns[:-1]]
from functools import reduce
reduce(lambda x, y: x*y, lines) # I'm not sure this is a clean way
yielding something like:
This is doing almost what I want. In particular, the hover tool, shows the x/y coordinates of the points under it. I want it to show the week of the corresponding curve. Lastly, is there a more pythonic way to do so? Maybe directly with bokeh?


