sdgaw erzswer
sdgaw erzswer

Reputation: 2382

Seaborn heatmap throws "isnan" type of error after update

I've been recently dealing with heatmaps in Python, more specifically, I've been drawing with the seaborn library. Up to some point, everything worked perfectly, my snippet looked something like:

result = df.pivot(index='indexcol', columns='coltwo', values='hvalues')
ax = sns.heatmap(result, cbar=False, yticklabels=True, xticklabels=True, linewidths=.1, cmap=ListedColormap(['white', 'green', 'red']))
plt.show()

where my result is a Pandas dataframe. After I updated to 0.8.2, it started to throw something like:

TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

I can fix this partially, by using result.astype(int) in the heatmap call, yet the plots do not look the same.

Apart from a downgrade, what options do I have?

Upvotes: 8

Views: 4848

Answers (1)

sdgaw erzswer
sdgaw erzswer

Reputation: 2382

Solved this with:

result.fillna(value=np.nan, inplace=True)

a row before the heatmap plot. The problem was, that the new seaborn couldn't handle None, yet numpy nan is apparently ok.

Upvotes: 8

Related Questions