Seaborn热图在更新后引发“ isnan”类型的错误

sdg*_*wer 5 python seaborn

我最近一直在处理Python中的热图,更具体地说,我一直在使用seaborn库。在某种程度上,一切都运行良好,我的代码段看起来像:

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()
Run Code Online (Sandbox Code Playgroud)

我的结果是一个熊猫数据框。在我更新到0.8.2之后,它开始抛出类似以下内容:

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''
Run Code Online (Sandbox Code Playgroud)

我可以通过result.astype(int)在Heatmap调用中使用来部分解决此问题,但这些图看起来并不相同。

除了降级,我还有什么选择?

sdg*_*wer 6

解决了这个问题:

result.fillna(value=np.nan, inplace=True)
Run Code Online (Sandbox Code Playgroud)

热图前的一行。问题是,新的 seaborn 无法处理 None,但 numpy nan 显然没问题。