I am trying to plot a stacked bar chart using bokeh by following this segment of the documentation. but my data frame is a tad more complex. it looks like this:
events count Name
a 2 jerry
b 1 jerry
a 8 joe
c 1 joe
b 4 megan
c 1 megan
... ... ...
data.user.nunique()
= 11 (will be in columns) and data.event.nunique()
= 167 (will be the stacked segments for each column note that not every user has raised all unique events)
so according to code from the docs and for the above segment of dataframe:
output_file("stacked.html")
names = data.Name.unique() # ['jerry','joe','megan']
events = data.events.unique() # ['a','b','c']
colors =["#c9d9d3", "#718dbf", "#e84d60"]
data = {'names' : names,
'a' : [2, 8, 0], # a raised 2 times by jerry, 8 times by joe , 0 times by megan
'b' : [1, 0, 4],
'c' : [0, 1, 1]}
my question is twofold, 1) how do I create the data
dictionary from my actual dataset?
2) is there any alternative approach to solving this problem?