在seaborn中使用distplot的FutureWarning [英] FutureWarning with distplot in seaborn

查看:73
本文介绍了在seaborn中使用distplot的FutureWarning的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试使用 seaborn 中的 distplot 时,都会出现此警告,但我似乎无法弄清楚我做错了什么,抱歉如果简单.

I have this warning that shows up whenever I try to use distplot from seaborn, and I can't seem to figure out what I'm doing wrong, sorry if it's simple.

警告:

FutureWarning:对多维使用非元组序列索引已被弃用;使用 arr[tuple(seq)] 而不是 arr[seq].将来这将被解释为数组索引,arr[np.array(seq)],这将导致错误或不同的结果.返回 np.add.reduce(sorted[indexer] * weights,轴=轴)/总和

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

这是一个可重现的例子:

Here a reproducible example:

import numpy as np 
import pandas as pd 
import random

import seaborn as sns

kde_data = np.random.normal(loc=0.0, scale=1, size=100) # fake data
kde_data = pd.DataFrame(kde_data)
kde_data.columns = ["value"]
#kde_data.head()

现在,情节是正确的,但我不断收到上面的 warning 并使用 arr[tuple(seq)] 而不是 arr[seq] 对我帮助不大.

Now, the plot is correct, but I keep getting the warning above and use arr[tuple(seq)] instead of arr[seq] doesn't help me much.

sns.distplot(kde_data.value, hist=False, kde=True)

我正在开发 Jupyter,这是模块版本:

I'm working on Jupyter, and this are the modules versions:

seaborn==0.9.0
scipy==1.1.0
pandas==0.23.0
numpy==1.15.4

推荐答案

您没有做错任何事情.目前没有办法摆脱这个警告,除了可能抑制它.

You are not doing anything wrong. Currently there is no way to get rid of this warning, other than possibly suppressing it.

这告诉你的是,seaborn 使用了一个 scipy 函数,由于最近的 numpy 版本中所做的更改,该函数将在未来改变行为.我希望在这里发生的是,在未来的 scipy 版本中,该功能将被更改为与未来 numpy 版本的任何过去完美配合.在此之前,您可能只是决定接受警告.它不会以任何方式恶化绘图结果.

What this tells you is that seaborn uses a scipy function that will change behaviour in the future due to a change made in a recent numpy version. What I expect to happen here is that in a future scipy release that function will be changed to work nicely with any past of future numpy version. Until then you may just decide to live with the warning. It will not deteriorate the plotting results in any way.

这篇关于在seaborn中使用distplot的FutureWarning的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆