0

I am using the code below to generate a heatmap on a table, but for some reason float numbers are getting additional decimal places. For example, 80.4 is becoming 80.400000 which kinda ruins the visualization. Is there any way to stop this? The numbers are normal in the df itself: rounded to 1 decimal place, as I need them to be.

df.style.background_gradient(cmap ='RdYlGn').set_properties(**{'font-size': '15px'})

One way I found to fix it is to turn float into int, but the decimal places are important here. I also have a "Average Rating" column ranging from ~5 to 10 and 2 decimal places, so int is not an option.

  • Can you provide a fully reproducible example? Use `seaborn` for easy annotations with a custom format. – mozway Aug 31 '23 at 02:35
  • What would be the best way to do it? I have some string columns and 3 numeric columns: GK (float 0 to 100), GK% (float -1 to 1), Average_Rating (float ~5 to 10). It's a Football Manager table – Henrique Mantovani Aug 31 '23 at 03:42

0 Answers0