Configure Hoverdata using values from a pandas.Dataframe column

I would like to add values in the hoverteplate inserted from the dataframe I’m extracting the data from:

fig7 = go.Figure(layout=layout) # Hover text and formatting in Python
fig7.add_trace(go.Bar(y=df_portfolio_projection[‘product_name’],
x=df_portfolio_projection[‘Total Product Cost (Unit)’],
hovertemplate=‘Total Asset Value (Unit): {x:,.0f}<br>' +'EBITDA Margin (%): %{y:,.0f}
’,
name=‘Total Product Cost (Unit)’,
orientation=‘h’,
marker=dict(
color=‘rgba(0, 131, 255, 0.6)’,
line=dict(color=‘rgba(0, 131, 255, 1.0)’, width=3)
)
))

An example of the frame columns would be the following:

df_portfolio_projection.columns                                                                             
Index(['Supplier', 'Expected Income', 'Average Daily demand', 'EBITDA (Unit)',
       'EBITDA (Container)', 'EBITDA Margin (%)',
       'Total Asset Value (Container)', 'Total Product Cost (Container)',
       'Total Shipment', 'Total Asset Value (Unit)',
       'Total Product Cost (Unit)', 'Total Shipment (Unit cost)',
       'Inventory cost (Container)', 'Units per container',
       ],
      dtype='object')

An example of what I would need to do is show in the tooltip are

Total Asset Value (Unit), ‘EBITDA Margin’, ‘Total Asset Value (Container)’

1 Like