thomas.mac
thomas.mac

Reputation: 1256

create heatmap for each row in pandas dataframe

Below is a df called "compmatrix":

             -3.0        -5.0       -7.0    
Gain/DD*DD%  0.009000    0.034000   0.088000    
Gain/Expsr%  0.487000    0.927000   1.628000    
Gain/MaxDD   0.015000    0.021000   0.025000    
MaxDD*iBeta  32.633      193.536    856.520

I'd like to apply a heatmap to each row (vs. the whole dataframe), because of the big difference in values.

import seaborn as sns
sns.heatmap(compmatrix,cmap='RdYlGn_r',annot=True)

but the fact that there's no axis=1 has thrown me off. Can't seem to find the solution I'm looking for in the documentation.

Upvotes: 2

Views: 2514

Answers (1)

thomas.mac
thomas.mac

Reputation: 1256

Found a handy solution to the problem (and no need for seaborn):

compmatrix.style.background_gradient(cmap='RdYlGn',axis=1)

Upvotes: 5

Related Questions