How to format numerical values of hovertext parameter?

I want to format numerical value in hovertext parameter like this “Sales: $34.6K”.

hoverinfo='text',
hovertext=
               '<b>Country</b>: ' + product_sales7[product_sales7['COUNTRY'] == w_countries]['COUNTRY'].astype(str) + '<br>'+
              '<b>Total Sales</b>: ' + product_sales7[product_sales7['COUNTRY'] == w_countries]['SALES'].astype(str) + '<br>'+
             '<b>Year</b>: ' + product_sales7[product_sales7['COUNTRY'] == w_countries]['YEAR_ID'].astype(str) + '<br>'


The above provided link works only in plotly. For example customdata property

customdata=product_sales1[['COUNTRY', 'PRODUCTLINE']],
  hovertemplate =
          '<br><b>Country</b>: %{customdata[0]}<br><extra></extra>'+
          '<b>Product</b>: %{customdata[1]}'+
          '<br><b>Quantity Ordered</b>: %{x:.2s}<br>'+
          '<b>Sales</b>: %{y:.2s}',

The above does not work in dash app.

The below code works in dash app. I need to improve more, for example, I want output value in K or M format (34.67K or 0.34M).

hovertext=
              
              '<b>Total Sales</b>: ' + [f'{x:,.0f}' for x in product_sales7[product_sales7['COUNTRY'] == w_countries]['SALES']] + '<br>'+
            

If I change 0f=0s to get values in K or M format, dash returns error. Any suggestion in code?

Hi,
try loking this:

Did you get any solution to it?