0

I have a table (which is currently produced in Excel), where a row wise comparison is made and each cell in a row is ranked from lowest to highest. The best score is strong green, the second best score is less green and the worst score is red. For cells with an equal score, the color of the cells will also be similar and based on their shared rank.

For some rows, the ranking is based on a ascending score, while some rows have a descending ranking.

How can this be done using Python? Do you know any modules that are capable of doing something similar? I've used Seaborn for other heatmaps, but none of them were based on a row wise comparison.

Any ideas?

The colors are not important. I just want to know how to rank the cells of each row compared to each other.

enter image description here

tigram10
  • 19
  • 2
  • Does [Coloring Cells in Pandas](https://stackoverflow.com/questions/28075699/coloring-cells-in-pandas) help you or is the table display by a plot a given? – MagnusO_O Sep 19 '22 at 20:36

1 Answers1

-1

Use background_gradient. The RdYlGn map sound like it matches your description. There won't be a 100% reproduction of Excel's color map.

df.style.background_gradient("RdYlGn", axis=1)

List of color maps: https://matplotlib.org/stable/tutorials/colors/colormaps.html

Mike Henderson
  • 2,028
  • 1
  • 13
  • 32