0

After upgrading to matplotlib 2.0 I have a hard time getting seaborn to plot a pairplot. For example...

sns.pairplot(df.dropna(), diag_kind='kde') returns the following error TypeError: slice indices must be integers or None or have an __index__ method. My data doesn't have any Nans in it. Infact, removing the kde option allows the function to run.

Any idea what is happening?

gincard
  • 1,564
  • 2
  • 15
  • 23
Demetri Pananos
  • 6,032
  • 6
  • 35
  • 68
  • Could you provide a [MCVE] as a test case that everyone can run and reproduce the error? This would help to identify if it is a problem depending on the data in use or a general problem between matplotlib, seaborn and pandas. – ImportanceOfBeingErnest Jan 20 '17 at 14:10

2 Answers2

0

Check the data type of the relevant variables. The error indicates that at least one of them is not an integer. It might be a float. If so, you'll need to recast the variable as an integer. Be careful if you have some very long numbers as these can round down when converting to an integer - see this question here for more information.

(Note, this works for me in Python 2.7, not sure if 3.+ is different).

Community
  • 1
  • 1
gincard
  • 1,564
  • 2
  • 15
  • 23
0

Looks like the problem was with statsmodels (which seaborn uses to do KDE). I reinstalled statsmodels and that cleared up the problem.

Demetri Pananos
  • 6,032
  • 6
  • 35
  • 68