发布于2019-09-02 19:42 阅读(2572) 评论(0) 点赞(4) 收藏(2)
我搜索过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'
更全面的追溯会很好。我的猜测是,seaborn.distplot
使用scipy.stats
计算的东西。发生错误
def _compute_qth_percentile(sorted, per, interpolation_method, axis):
....
indexer = [slice(None)] * sorted.ndim
...
indexer[axis] = slice(i, i + 2)
...
return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval
所以在最后一行中,列表indexer
用于切片sorted
。
In [81]: x = np.arange(12).reshape(3,4)
In [83]: indexer = [slice(None), slice(None,2)]
In [84]: x[indexer]
/usr/local/bin/ipython3:1: 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.
#!/usr/bin/python3
Out[84]:
array([[0, 1],
[4, 5],
[8, 9]])
In [85]: x[tuple(indexer)]
Out[85]:
array([[0, 1],
[4, 5],
[8, 9]])
使用切片列表有效,但计划将来会贬值。涉及多个维度的索引应该是元组。在上下文中使用列表是一种正在逐步淘汰的旧样式。
所以scipy
开发人员需要解决这个问题。这不是最终用户应该处理的事情。但就目前而言,不要担心futurewarning
。它不会影响计算或绘图。有一种方法可以抑制未来的警告,但我不知道它是什么。
FutureWarning:不建议使用非元组序列进行多维索引使用`arr [tuple(seq)]`而不是`arr [seq]`
作者:黑洞官方问答小能手
链接:https://www.pythonheidong.com/blog/article/82795/4672230162f9617b9eb8/
来源:python黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 python黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-1
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!