Py学习  »  Python

在Python中使用Seabn绘图时,如何修正“未来警告:使用非元组序列进行多维索引”?[副本]

Shubham Gupta • 5 年前 • 1969 次点击  

我已搜索过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 ,肖伯恩: 0.9.0 ,matplotlib: 2.2.3 ,科学: 1.1.0 ,努比: 1.15.0'

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/49327
 
1969 次点击  
文章 [ 4 ]  |  最新文章 5 年前