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 图:
但是当系列的元素被修改为:
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)