相关疑难解决方法(0)

如何抑制熊猫未来警告?

当我运行程序时,Pandas每次都给出如下所示的"未来警告".

D:\Python\lib\site-packages\pandas\core\frame.py:3581: FutureWarning: rename with inplace=True  will return None from pandas 0.11 onward
  " from pandas 0.11 onward", FutureWarning) 
Run Code Online (Sandbox Code Playgroud)

我得到了消息,但我只想阻止Pandas一次又一次地显示这样的消息,是否有任何buildin参数我可以设置让Pandas不会弹出'Future warning'?

suppress-warnings pandas

92
推荐指数
5
解决办法
6万
查看次数

FutureWarning:不推荐使用非元组序列进行多维索引使用`arr [tuple(seq)]`

我搜索过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()
Run Code Online (Sandbox Code Playgroud)

这是警告:

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 …
Run Code Online (Sandbox Code Playgroud)

python scipy python-3.x pandas seaborn

20
推荐指数
3
解决办法
1万
查看次数

seaborn 未在定义的子图中绘制

我正在尝试使用此代码并排绘制两个分布图

fig,(ax1,ax2) = plt.subplots(1,2)

sns.displot(x =X_train['Age'], hue=y_train, ax=ax1)
sns.displot(x =X_train['Fare'], hue=y_train, ax=ax2)
Run Code Online (Sandbox Code Playgroud)

它返回以下结果(两个空的子图,后跟一个分布在两行上的图)-

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

如果我用 violinplot 尝试相同的代码,它会按预期返回结果

fig,(ax1,ax2) = plt.subplots(1,2)

sns.violinplot(y_train, X_train['Age'], ax=ax1)
sns.violinplot(y_train, X_train['Fare'], ax=ax2)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

为什么 displot 返回不同类型的输出,我该怎么做才能在同一行上输出两个图?

python data-visualization seaborn

10
推荐指数
1
解决办法
5567
查看次数