相关疑难解决方法(0)

seaborn:选择的 KDE 带宽为 0。无法估计密度

import pandas as pd
import seaborn as sns

ser_test = pd.Series([1,0,1,4,6,0,6,5,1,3,2,5,1])
sns.kdeplot(ser_test, cumulative=True)
Run Code Online (Sandbox Code Playgroud)

上面的代码生成以下 CDF 图:

系列的 CDF (ser_test)

但是当系列的元素被修改为:

ser_test = pd.Series([1,0,1,1,6,0,6,1,1,0,2,1,1])
sns.kdeplot(ser_test, cumulative=True)
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

ValueError: 无法将字符串转换为浮点数:'scott'

运行时错误:选定的 KDE 带宽为 0。无法估计密度。

这个错误是什么意思,我如何解决它以生成 CDF(即使它非常倾斜)。

编辑:我使用的是 seaborn 版本 0.9.0

完整的跟踪如下:

ValueError: could not convert string to float: 'scott'

During handling of the above exception, another exception occurred:

RuntimeError                              Traceback (most recent call last)
<ipython-input-93-7cee594b4526> in <module>
      1 ser_test = pd.Series([1,0,1,1,6,0,6,1,1,0,2,1,1])
----> 2 sns.kdeplot(ser_test, cumulative=True)

~/.local/lib/python3.5/site-packages/seaborn/distributions.py in kdeplot(data, data2, shade, vertical, kernel, bw, gridsize, …
Run Code Online (Sandbox Code Playgroud)

python data-visualization kernel-density pandas seaborn

11
推荐指数
2
解决办法
3万
查看次数