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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With