运行代码如下:

df = pd.read_csv('data.csv')
df.head()

df.describe()

plt.figure(figsize=(12,10))
cor = df.corr()
sns.heatmap(cor, annot=True, cmap=plt.cm.YlGn)
plt.show()

报错:

FutureWarning: The default value of numeric_only in DataFrame.corr is deprecated. In a future version, it will default to False. Select only valid columns or specify the value of numeric_only to silence this warning.
  cor = df.corr()

翻译:

FutureWarning:DataFrameGroupBy.mean 中的默认值 numeric_only 已弃用。在将来的版本中,numeric_only将默认为 False。指定numeric_only或仅选择对函数有效的列

解决方法:

指定numeric_only=True,警告消失

df = pd.read_csv('data.csv')
df.head()

df.describe()

plt.figure(figsize=(12,10))
cor = df.corr(numeric_only = True)
sns.heatmap(cor, annot=True, cmap=plt.cm.YlGn)
plt.show()

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐