我试图做我的实验室练习,但出现错误,但我不知道问题是什么以及在哪里修复它。谁能告诉我问题是什么,以便我可以解决它?这是代码:
f, ax = plt.subplots (figsize = (10, 10))
sns.heatmap (df.corr (), annot = True, linewidths = .5, fmt = '.1f', ax=ax)
plt.show ()
然后出现以下输出:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[7], line 2
1 f, ax = plt.subplots (figsize = (10, 10))
----> 2 sns.heatmap (df.corr (), annot = True, linewidths = .5, fmt = '.1f', ax=ax)
3 plt.show ()
ValueError: could not convert string to float: 'Switzerland'
看来您可能已将
sns
定义为不正确的内容,因为您从未在上面的示例代码中定义过它。我假设您之前在代码中定义了 sns