7

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.

Warning:

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()

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)

enter image description here

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
RLave
  • 8,144
  • 3
  • 21
  • 37

2 Answers2

9

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

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.

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
  • Hiding a warning can lead to unexpected behavior (sometimes more serious, such as non-convergence of an algorithm). The package authors have place warnings for a reason. [Here is a way](https://stackoverflow.com/a/63895570/3043335) to avoid this particular one. – Oleg Melnikov Jan 27 '21 at 22:28
0

In this thread, they point out that it is an issue with scipy and that upgrading to scipy>=1.2 should solve the issue.

nocibambi
  • 2,065
  • 1
  • 16
  • 22