简体   繁体   English

Seaborn Pairplot不显示KDE

[英]Seaborn pairplot not showing KDE

After upgrading to matplotlib 2.0 I have a hard time getting seaborn to plot a pairplot. 升级到matplotlib 2.0后,我很难下定决心绘制对图。 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 . sns.pairplot(df.dropna(), diag_kind='kde')返回以下错误TypeError: slice indices must be integers or None or have an __index__ method My data doesn't have any Nans in it. 我的数据中没有任何Nan。 Infact, removing the kde option allows the function to run. 实际上,删除kde选项将允许该函数运行。

Any idea what is happening? 知道发生了什么吗?

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). (请注意,这在Python 2.7中对我有效,不确定3. +是否不同)。

Looks like the problem was with statsmodels (which seaborn uses to do KDE). 看起来问题出在statsmodels(seaborn用于做KDE)。 I reinstalled statsmodels and that cleared up the problem. 我重新安装了statsmodels,这解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM