python - Organize Data that is Callable to Hovertool -


i'm confused how make hover tool call 2 main variables of stacked bar plot.

my pivot_table below. company names first column, , months along top row. number number of calls in month each customer.

pivot_table.head(2) out[4]:  month                              1   2   3   4   5   6   7   8   9   10  11  companyname                                                                      company1     17  30  29  39  15  27  23  12  36  21  18    company2   4  11  13  22  34  27  16  18  29  31  17     month                              12   companyname                             company1     15   company2     14   

here code

# months jan = pivot_table[1].astype(float).values feb = pivot_table[2].astype(float).values mar = pivot_table[3].astype(float).values apr = pivot_table[4].astype(float).values may = pivot_table[5].astype(float).values jun = pivot_table[6].astype(float).values jul = pivot_table[7].astype(float).values aug = pivot_table[8].astype(float).values sep = pivot_table[9].astype(float).values oct = pivot_table[10].astype(float).values nov = pivot_table[11].astype(float).values dec = pivot_table[12].astype(float).values # build dict containing grouped data  months = ordereddict([('jan', jan), ('feb', feb), ('mar', mar), ('apr',apr), ('may',may), ('jun',jun),('jul',jul), ('aug',aug), ('sep',sep),('oct',oct),('nov',nov),('dec',dec)])     hover = hovertool(     tooltips = [         ("month", "@months"),         ("number of calls", ""),         ] ) output_file("stacked_bar.html") bar = bar(months, companies, title="stacked bars", legend = "top_right", width = 1200, height=900, stacked=true) bar.add_tools(hover)  show(bar) 

the part i'm not sure how call variables this:

hover = hovertool(     tooltips = [         ("month", ""),         ("number of calls", ""),         ] ) 

i've tried making big list number of calls part way: numbercalls = pivot_table.stack().astype(int).tolist() know bar doesn't support columndatasource, i've used before. i've tried calling "@months" it's ordereddict it's not calling right. bonus if there way months in loop rather 1 one!


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -