【发布时间】:2019-03-06 17:56:46
【问题描述】:
我已经搜索了 S/O,但找不到答案。
当我尝试使用 seaborn 绘制分布图时,我收到了一个未来警告。我想知道这里可能是什么问题。
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
% matplotlib inline
from sklearn import datasets
iris = datasets.load_iris()
df = pd.DataFrame(iris.data, columns=iris.feature_names)
df['class'] = iris.target
df['species'] = df['class'].map({idx:s for idx, s in enumerate(iris.target_names)})
fig, ((ax1,ax2),(ax3,ax4))= plt.subplots(2,2, figsize =(13,9))
sns.distplot(a = df.iloc[:,0], ax=ax1)
sns.distplot(a = df.iloc[:,1], ax=ax2)
sns.distplot(a = df.iloc[:,2], ax=ax3)
sns.distplot(a = df.iloc[:,3], ax=ax4)
plt.show()
这是警告:
C:\ProgramData\Anaconda3\lib\site-packages\scipy\stats\stats.py:1713:
FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated;
use `arr[tuple(seq)]` instead of `arr[seq]`.
In the future this will be interpreted as an array index, `arr[np.array(seq)]`,
which will result either in an error or a different result.
return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval
有什么帮助吗?你可以运行上面的代码。你会收到警告。
熊猫:0.23.4,seaborn:0.9.0,matplotlib:2.2.3,scipy:1.1.0,numpy:1.15.0'
【问题讨论】:
-
我在运行代码时没有收到该警告。也许您想分享您正在使用的 pandas、matplotlib、scipy、numpy 和 seaborn 的哪些版本?我想更新它们可以防止这种情况发生。
-
@ImportanceOfBeingErnest Pandas:
0.23.4和 seaborn:0.9.0,matplotlib:2.2.3,scipy:1.1.0,numpy:1.15.0' -
好的,这是因为使用了 numpy 1.15(我不会使用 numpy 1.14.6)。稍后我可能会更深入地了解哪个软件包会带来这个问题。
-
所以minimal reproducible example 是
sns.kdeplot(data = [1,3,4])。因此,我想这在 seaborn 的某个地方是个问题。 -
不,较旧的 seaborn 版本无法解决此问题。要摆脱警告,您可以安装较旧的 numpy 版本(例如 1.14.6);但该警告目前无害。人们希望 scipy 在 numpy 删除对索引的列表支持之前发布一个新版本。我非常有信心这会发生。
标签: python python-3.x pandas scipy seaborn